Reputation: 27384
I am trying to match a specific character with a number followed by a full stop, i.e. V1.
or V2.
I decided to start with just trying to match the character and number but it doesnt seem to be working, after numerous Google searches I believe this to be correct but obviously it isnt. TIA
var regex = new Regex("\b[V][0-9]\b")
var replaced = regex.Replace(path, string.Empty);
Upvotes: 0
Views: 926
Reputation: 174696
The below regex would match V
plus the ollowing one or more numbers only if it's followed by a dot.
new Regex(@"\bV\d+\.")
Explanation:
\b
Word boundary which matches between a word character and a non-word character.V
Matches a literal V
\d+
Matches one or more digits. Use only \d
if the following number is a single digit number.\.
Matches a literal dot.Upvotes: 1