Regex - Find biggest possible match, which would have been found without preceding word checking, or nothing -
i not know exact terminology , therefore unfortunately not find solution particular case.
i know how find single word, not proceeded predefined word using negative lookahead. example
my goal match biggest possible phrase, matched without added check preceding word. if following comma, not want of matches in group. if no comma ahead, want of them in 1 phrase.
my basic idea normal regex , check again if there comma in front of match. can done in 1 pass, though?
example (stupid one): house 566 819 , 94841 681 , nice 4571 68484 81981
ideal output:
566 819
4571 68484 81981
i want numbers matched, not directly follow comma (desired matches bold), 1 big match.
my current regex case looks this:
\b(?!,)\s((\d+\s*)+)
it finds 681 because number , no comma in front. unwanted behavior me.
i hope explained problem enough. there way achieve goal?
the regex
(?<=[^,\d]\s|^)(\d+(?:\d+\s*)+)
will match longest number , whitespace combo directly preceded ^
(beginning of line) or [,\d]\s
(a comma or digit followed whitespace).
is looking for? had hard time understanding question went based on:
i want numbers matched, not directly follow comma
Comments
Post a Comment