my input string looks this:
employee: joe banana department: sales location: new york bla bla bla note: more bla
this regex trick extracting full name, i.e. joe banana
(?s).*(?-s)(?m)^\s*(employee): .*\s(.*)$(?-m)(?s).*(?-s)(?m)^\s*(note):$(?-m)(?s).*
however doesn't work first name, extract department instead:
(?s).*(?-s)(?m)^\s*(employee): (.*)\s.*$(?-m)(?s).*(?-s)(?m)^\s*(note):$(?-m)(?s).*
why don't these regex extract first name , last name?
i need keep searching groups need stop searching after note:
try one, first match group first name second match group last name :
(?m)^employee:\s+(w+)\s+(w+)
or replace (.*) (w+)\s+(w+) in regex :
(?s).(?-s)(?m)^\s(employee): .\s(w+)\s+(w+)$(?-m)(?s).(?-s)(?m)^\s*(note):$(?-m)(?s).*
Comments
Post a Comment