regex - powershell complicated regular expression -
i've been stuck trying write regular expression matches following condition. basically, have text file contains several text lines (composed of words , digits). example:
some_text number 45 some_text ptrn: anchor some_text number 22 some_text
what need return “45” (or other digits after word “number”), in case in line found “ptrn: anchor”. again, if pattern “ptrn: anchor” has been found in line, script should look back along line until gets first word “number” , output digits beside it.
i'm not @ regular expressions , appreciate help.
this should do:
"number\s*(\d+).*ptrn: anchor"
note if there multiple numbers before ptrn: anchor
in single line, first 1 returned.
Comments
Post a Comment