Forum Discussion

tipper1510's avatar
tipper1510
Brass Contributor
Jun 28, 2024

String functions within playbooks

Hi,

 

Have the following string that I need to tidy up:

 

"hostname","{\r\n \"LastLog\": [\r\n \"2024-06-25T16:15:35.751991Z\"\r\n ]\r\n}"

 

so it can have

 

hostname   2024-06-25 16:15:35

 

I have attempted to combine replace statements with no luck...

 

Any ideas..

 

Many thanks,

 

Tim

  • Clive_Watson's avatar
    Clive_Watson
    Bronze Contributor

    tipper1510 

     

    Hello, you probably should look at extract() or even parse() - assuming this is KQL within the playbooks?


    Here is a simple example to get you going

     

    let txt = '"hostname","{\r\n \"LastLog\": [\r\n \"2024-06-25T16:15:35.751991Z\"\r\n ]\r\n}"';
    print txt
    | parse txt with *'"' HostName_ '"' *
    | parse txt with *'[\r\n \"' Date_ '\"\r\n ]' *

     

     

Resources