digits - Regex to match 3 numbers -
Currently, I'm trying to create a regex, which can get 3 numbers under some circumstances. I have tried many attempts now, but it will not work with a single expression - it either matches "bad positive" or "wrong numbers" ...
words : I have to get any 3 points which If: in examples Strong> (the number that I want to match) in (I This is needed (1 number) (2 numbers) - but this will only be a bit change in the match of 3 numbers) My last attempt looks like this: However this fails in the final case. I used it for However, now a teststring like "101 202" is positive because first check matches Any thoughts? Note: It should work on various regex engines, no matter what php, javascript, java, .net or ook! :) We can write the numbers you are looking for like this: Then the whole expression is: After the line ends the two numbers using a negative lookhead, start the anchor, then matches a valid number. Interpolated expression looks useless: This perl code: produces:
() :
( ?: [^ X] | ^) (\ D {1}) (\ d {2}) [^ pi]
preg_match_all (... ) === 1 with this Tried to make sure, only one result was matched
101 (with white spot ) And then does not match the
202 , which assumes the pattern that
101 is the only legitimate solution - which is false.
( ?: [^ x] | ^) (\ d {1}) (\ d {2}) [^ pi]
re_n = (?: [^ X] | ^) \ d \ d \ d (?: [^ Ip] | $)
^ (?!. Re_n. * Re_n. * $) * (Re_n)
/ ^ (?!. * (?: (? ^ [^ X] | ^) \ d \ d \ d ( [^ Ip] | $)) * (: ([^ x] | ^) \ d \ d \ d (:. ?? [^ ip] | $). * $). * ([? ^ [^ X] | ^) \ d \ d \ d (?: [^ Ip] | $))) /
my $ re_n = qr / (?: [^ X] | ^) \ d \ d \ d (?: [^ Ip] | $) /; While (& lt; data & gt;) {chomp; If (/ ((??) .. ***************** "$ _: $ 1 \ n";} Other {print "$ _: none" \ "";}} __DATA__ This is a 321 example. 321 in 321 is not basically possible, but can not hurt. There is another group with P: 122p this 321 is another group I: 123i This x235 should be ignored because the reason 123 is what I want to match is 123 which is what I want, not 111 in this case x111 Or there is no solution in 125p or 999i 555
this 321 An example is: 321 321 also: 321/321 is not basically possible, but can not hurt: 321 This 321 has another group with AP: 122 P: 321 In 321 this is the second group with I: 123i: 321 This X-235 should be sponsored because the 123 which I want to match: 123 123 I do not want, x111 or 125p or 999i: 123 There is no solution in this 111 case 555: No
Comments
Post a Comment