Re: RegEx with phix - howto
- Posted by petelomax Jul 03, 2018
- 1256 views
begin said...
yes thank you. i tried that an many others but phix returns
^10.\d{4,9}[^\s]+$ ^invalid escape (negation mismatch)
That's probably a bug. Workaround below. I've not been well for the past few days (nothing serious, just a touch of man-flu, again) and my head's still groggy, but I'll take a closer look when my head clears.
_tom said...
? where does the trailing `l` come from?
As per the docs: "The result is pairs of start/end+1 indexes", plus your regular expression has a trailing space.
I tried this (in lieu of trying to fix anything):
include builtins\regex.e sequence line = "lorum ipsum lorum ipusm 10.1016.12.31/nature.S0735%20-1097(98)2000/12/31/34:7-7 lorum ipsum.", rx = `10.\d{4,9}\S+`, res = regex(rx,line) integer {s,e} = res ?line[s..e-1]
ie: I used \S instead of [^\s], and you don't use the outer ^$ unless you need the whole string to match, and I got:
"10.1016.12.31/nature.S0735%20-1097(98)2000/12/31/34:7-7"
Pete