Reputation: 3469
I want to match any number after the letter v
.
So,
v: 123
matches 123
;v 123
matches 123
;v123
matches 123
.But i want to ignore any match when there's any letter behind v
.
Like xv: 123
must not match anything.
I'm working with this pattern:
/v[\s\pP]*(\d+)/
but it doesn't ignore situations when somethingbehindv: 123
.
Upvotes: 0
Views: 375
Reputation: 8467
An alternative solution would be to use a negative look-behind assertion. This is an extended regular expression and may not supported in whatever language or platform you're using. It would look something like this:
/(?<!\S)v[\s\pP]*(\d+)/
Which basically prevents the pattern from matching if any non-whitespace character(s) (\S
) precede the v
. You can tweak this, of course, if other characters should be disallowed.
Upvotes: 1