regex - Search SubStrings between defined Strings or at the end of defined strings with Vbscript compatible Regular expression -
i have parse specific information report headers in text format
since have perform through regular expressions in vb script cannot make use of ahead features of regex.
typical use cases cover regular expressions
1) user name : clark kent
extracted regex: "clark kent
" line starting "user name :
"
2) user name clark kent
extracted regex: "clark kent
" line starting "user name
" , delete leading , trailing blanks " clark kent
"
3) user name: clark kent sample id : 1234
extracted regex: "clark kent
" line starting "clark kent
" , ending "sampleid :
"
any example highly appreciated
my regex skills aren't greatest pattern works 3 examples. looks , returns <first name><space><last name>
, adapted handle more complicated scenarios.
with new regexp .pattern = "^user name\s*:?\s*(\w+\s\w+)\s*(?:sample id)?" set matches = .execute(strline) end if matches.count > 0 strname = matches(0).submatches(0)
Comments
Post a Comment