I have this URL:
http://example.com/createSend/step4_1.aspx?cID=876XYZ964D293CF&snap=true&jlkj=kjhkjh&
And this regex pattern:
cID=[^&]*
Which produces this result:
cID=87B6XYZ964D293CF
How do I REMOVE the "cID="?
Thanks
Example: "a\+" matches "a+" and not a series of one or "a"s. ^ the caret is the anchor for the start of the string, or the negation symbol. Example: "^a" matches "a" at the start of the string. Example: "[^0-9]" matches any non digit.
You can either use lookbehind (not in Javascript):
(?<=cID=)[^&]*
Or you can use grouping and grab the first group:
cID=([^&]*)
Generally speaking, to accomplish something like this, you have at least 3 options:
substring
of the match jsref
- substring
Given this test string:
i have 35 dogs, 16 cats and 10 elephants
These are the matches of some regex patterns:
\d+ cats
-> 16 cats
(see on rubular.com)\d+(?= cats)
-> 16
(see on rubular.com)(\d+) cats
-> 16 cats
(see on rubular.com) 16
You can also do multiple captures, for example:
(\d+) (cats|dogs)
yields 2 match results (see on rubular.com) 35 dogs
35
dogs
16 cats
16
cats
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