I have a requirement to extract 3 different key pairs from the long string and store it in a dictionary variable .
if my string is as below
" here are the details of your incident
Description: your issue is related to application . But please cross check ;
Resolution: your application can be restarted to resolve this .Please try ;
and the root cause fix is
Root Fix: please make code level changes ;"
and my result should be
Result enumerable dictionary,
( Description:your issue is related to application . But please cross check ,
Resolution: your application can be restarted to resolve this .Please try ,
Root Fix: please make code level changes )
Please help me in this .
I have seen regex can be used to fetch any one key pair but i want to extract all three key pairs .
Do one thing
Read text file
and use add to dictionary
and use for each item
Print the item
Thanks for the repl .
Adding keypair to dictionary is not the problem here .
I need a way to remove those keypairs out of my string .
Pass the key value pairs to remove from dictionary
Hope these steps would help you resolve this
If the above string is in a string variable named str_input
Then use a assign activity like this
arr_str = Split(str_input,”;”)
Where arr_str is a variable of type array of string
Now use a FOR EACH activity and pass the above variable as input
Inside the loop use a assign activity like this
dic_string(Split(item.ToString,”:”)(0).Tostring.Trim) = Split(item.ToString,”:”)(1).ToString.Trim
Where dic_string is a variable of type dictionary(of string) with default value as Nee Dictionary(of string,string)
hey @Abhishek_Aithal1 how are you using regex to get only one line item
Thanks for the detailed explanation.
Could you please let me know if there is any way to remove extra words that is comming us in the key position .
example in the above string
“here are the details of your incident
Description: your issue is related to application . But please cross check ;” would be one of the item in list of strings and “here are the details of your incident
Description” would be the key of this dictionary variable .
But i need only “Description” as key .
Would this be possible from regex function to check if the key has “description/Resolution/Root fix” any of these three then consider only this as key expression .
Its not number format , I think so each number they added in a img Format.
yah we can do that
but we need a structure of string for that
will the string contains the terms like Description, Resolution and Root Fix in order
because we can get the string between Description and Resolution a value for Description
similarly string between Resolution and Root Fix as a value for key Resolution
try this regex to get those three line items
further you can split every line by colon “:” to get it in key value pair
u can also use ismatch activity with same expression to check whether those keywords exist or not
You can use regex for this as it’s much faster and stable.
If you’re very sure that all three (Description, Resolution, Root Fix) will be present, you can use the following regex to get all the three item in an array.
Else if you need to get specific one, you need to use the following for each
(?<=Description:).*?(?=\;) - Description
(?<=Resolution:).*?(?=\;) - Resolution
(?<=Root Fix:).*?(?=\;) - Root Fix
Hope this help!
This worked .But one small changes needed .
expression doesnt pics the string in the next line .
" description: this is first line .
this is second line .
this is thrird ;
and this is some random redundant line "
“description: this is first line .
this is second line .
this is thrird ;”
“description: this is first line .”
Could you please help me in this
@Abhishek_Aithal1 , how you resolved this issue? Any update. I have the exact requirement.
I would be thankful, if you could share your solution?