I need a Regular Expression that matches everything after the first two characters in a string.
For Example (original string listed first, then what I'd like to match):
AZ0bc1234 > 0bc1234
50def123 > def123
!@hijk1234 > hijk1234
All that matters is position, any characters (alpha-numeric with symbols) could be included in the original string.
I've tried many things, but everything I attempt matches at least one of the first two characters. The closest I've come is using \\B.*
to match everything but the first character.
If you want everything but the first two characters, you could try this (to capture up to the end of each line):
".{2}(.*)$"
You are after the first group (in parens). Or differently:
"(?:.{2})(.*)$"
You were looking for a positive lookbehind . this will only match the part you've requested.
(?<=.{2})(.*)$
You've updated your question and wrote that you use JavaScript. Lookbehind is not supported in JavaScript. However I will leave this answer for future search results.
The following will hold the matching string in the capturing group (define by the parenthesis) :
^.{2}(.+)
You should be able to use it with $1
or \\1
depending on the language.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.