Reputation: 687
I want to match \''
in string Apple MacBook Air 45\''
but my regex does not seem to work:
(?=[0-9]+)(\\'')
How to use possitive lookhead correctly? Or I need something else? I do not want to match using just (\\'')
regex.
Upvotes: 0
Views: 62
Reputation: 12389
You need a lookbehind. In most flavors this can only be of fixed width, which should be sufficient:
(?<=[0-9])\\''
or as php pattern: $pattern = "/(?<=[0-9])\\\\''/";
As you just want to check, if there is at least one [0-9]
before \''
.
Upvotes: 1