This question already has answers here:
A regex to match a substring that isn't followed by a certain other substring
(5 answers)
Closed 3 years ago.
How to mark xy if the next symbol is not y?
I have four strings:
1. zxyy
2. zxyz
3. zxy
4. xy
The epxression should mark strings 2-4.
This regex marks the 2-nd string only:
([x][y])(?=[^y])
Thanx.
The regex recommended by Aaron works as I wished:
xy(?!y)
It marks 2. zxyz 3. zxy 4. xy, but not 1. zxyy.
Related
This question already has answers here:
Using explicitly numbered repetition instead of question mark, star and plus
(4 answers)
Closed 4 months ago.
This should match
1233232985 John Doe
This should not match
John Doe 47437363
What I have attempted.
^\d{10-12}
Maybe this will help
"^[0-9]{10}$|^[0-9]{12}$"
This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 2 years ago.
For example, I would like to find ty in:
erytypotym5ty
etytyty
koetymitywty
or il in:
keililmil
ilwrilltyil5ile
^.*(\w{2}).*\1.*\1.*$.
The two letters (also digits and _; you could replace \w with [a-zA-Z], if you don't want them) will be in group 1.
https://regex101.com/r/11Oq70/1
This question already has answers here:
How can I match "anything up until this sequence of characters" in a regular expression?
(15 answers)
Closed 3 years ago.
I have strings that are concatenations of airline codes/flightnumbers, separated with ;. The airline code and flight number are either separated by a space or -. So some examples are:
AA-1234;UA 243;EK 23;
9W 23;B6-134
Now I want to grab the airline codes from this.
I came up with the following regex: [a-zA-Z0-9]{2}[ -]. This works to grab the airline codes but also includes the airlinecode-flightnumber separator. How would I adjust my regex to not include this?
[a-zA-Z0-9]{2}(?=[ -])
See it in action here
This question already has an answer here:
Learning Regular Expressions [closed]
(1 answer)
Closed 5 years ago.
I want regex with at least 2 characters start with any alphabet or any digit not matters.But It can accept - and _ .
Ex : ABD , Abc_123 , 12, A-_ , A1 etc.
(Updated)
(?=[-\w]{2}).*
Online test, https://regex101.com/r/JcUaBz/2
This should do the trick:
[\w-]{2,}
But, if you want to ignore words that have special characters, you can use this:
(?<=\s|^)([\w-]{2,})(?=\s+|$)
This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 5 years ago.
I have a character set {x, y, z} and I want to check if some string contains at least one character from this set.
For example:
abxyz - valid
zabc1 - valid
abc4e - not valid
/.*[xyz].*/ should do the trick
Try this regex:
.*[x-z].*
This will only match lines that include [x-z] at least once.
Example