php - Regex Lookarounds, prevent ahead and behind -
i have regex cannot working right. using pcre(php) run it.
the regex looks inch measurements written fractions using forward slash separate numerator , denominator. ex 1 3/8in or 19 15/16"
it match 12 1/2" here:
a product description 12 1/2" in it.
but want not match if measurement part of dimension, ie has x before or after , matches format: 19 3/4" x 19 5/8"
example text matching incorrectly:
product description 19 3/4" x 19 5/8" in it.
this matches 5/8" when supposed ignore of because of x in there.
my regex knocks off measure left of x, ignores whole number on right side. lookbehind capture 5/8" example above. need ignore both sides of dimension , match measurements themselves. using negative ahead , behind match x.
regex:
/\s+(?<!x\s)\d*\s?\d+\/\d+"*\s*(in|")(?!\d*\s?x)\s*/i
i ran through regex101.com's debugger , still can't figure out. reading.
with pcre/php use (*skip)(*fail)
\d*\s?\d+\/\d+"*\s*(in|")\sx\s\d*\s?\d+\/\d+"*\s*(in|")(*skip)(*fail)|\d*\s?\d+\/\d+"*\s*(in|")
Comments
Post a Comment