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

Popular posts from this blog

javascript - How to diff two immutable objects -

javascript - React.js: onClick function from child to parent -

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -