I’m new to regular expressions and i’m feeling this very difficult to solve:
I have a the following string:
"inforun 7970 12423 99 10:03 ? 00:09:03 abcd -PR -gmh domain.den.abc.com -gmp 6020 -guid 9c06cc02-b1c8-41cf-93e6-1d795e9fff62 -rst 180 -s FOLDER_NAME:wkf_workflow.s_session -something Session task instance [session]"
I have to extract the time which 10:03 and the 'domain' in domain.den.abc.com and the FOLDER_NAME, the 'workflow' in the 'wkf_worklfow' and the 'session' in the 's_session' the time, domain, foldername, workflow and session keep changing for every string and there are a bunch of strings like this all attached as a single string.
Here are the patterns that are common for every string. the 'abcd -PR -gmh' is common and can help in finding the time that is just before the '?'
the '-s', ':wkf' is common for all the string and the folder_name is right in between these two.
the 'workflow' is in between 'wkf_' and '.s_'
the session is in between 's_' and the immediate next '-'
I need the time, domain, folder name, workflow and session all in seperate strings.
I tried to practice regular expression only a few days back it is taking so much time for me even to comprehend something like "\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z" which is given here
Thank you for your help
Regex (time
$1, domain$2, folder name$3, workflow$4, session$5):Ruby:
Output:
See and test the code here.