RegEx - accept all numeric characters after a text character

Given a string in the format: XXX999999v99 (where X is any alpha character, v is any numeric character, and v is the literal v character), how can I get a regular expression to match the numeric characters following v? So far I have "v \ d \ d" which includes v, but ideally I would like only the digital part.

How does anyone know a tool where you can specify a string to match and create a regular expression? Changing an existing regular expression is one thing, but I find, starting from scratch, painful!

Edit: After re-reading this question, I understand that it reads like homework! However, I can assure you that the lines I'm trying to match are product versions added to product codes. The current code uses all kinds of substring expressions to extract part of the version.

+5
source share
3 answers

You can try:

v(\d+)$
  • v: matches the letter v
  • \d: one digit
  • \d+: one or more digits.
  • (): grouping that also remembers the agreed part that can be used later
  • $: snapping end of line
+4
source

You need a capture group:

Regex.Match("XXX999999v99",@"v(\d+)").Groups[1].Value
+2
source

.

: regex powertoy

: RegExr

There are also some paid programs like regex buddy

+1
source

All Articles