06-05-2007, 05:24 AM
Example
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]+.
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]+.