What regular expression can I use to find this?
&v=15151651616
Where &v=
is a static string and the number part may vary.
To match any number from 0 to 9 we use \d in regex. It will match any single digit number from 0 to 9. \d means [0-9] or match any number from 0 to 9. Instead of writing 0123456789 the shorthand version is [0-9] where [] is used for character range.
Match any specific character in a setUse square brackets [] to match any characters in a set. Use \w to match any single alphanumeric character: 0-9 , a-z , A-Z , and _ (underscore). Use \d to match any single digit. Use \s to match any single whitespace character.
?= is a positive lookahead, a type of zero-width assertion. What it's saying is that the captured match must be followed by whatever is within the parentheses but that part isn't captured. Your example means the match needs to be followed by zero or more characters and then a digit (but again that part isn't captured).
"^&v=[0-9]+$"
if you want at least 1 number or "^&v=[0-9]*$"
if no number must match too.
If you want it to match inside another sequence just remove the ^
and $
, which means the sequence beginning by (^)
and sequence ending with ($)
You can use the following regular expression:
&v=\d+
This matches &v=
and then one or more digits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With