Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular Expression Help
#2
Example

Code:
Copy      Help
str s=
;Name: John Doe
;;;MRN: 12345678
;;;exam: xray


str s2 s3
if(findrx(s "(?m)^ *Name: *([^[]]+)" 0 0 s2 1)<0) ret
out s2
if(findrx(s "(?m)^ *MRN: *([^[]]+)" 0 0 s3 1)<0) ret
out s3

Explanation

(?m) - sets ^ and $ to match beginning and end of a line instead of whole string.
* - 0 or more spaces.
() - store the enclosed part into s2.
[^[]]+ - 1 or more any characters except new line characters. Note: [] is QM escape sequence, not a part of regex syntax. Using regex syntax it would be [^\r\n]+.


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)