This question already has answers here:
How to write a regex which matches all char-sequences without 'aaa'
(2 answers)
Closed 7 years ago.
I need a regex, idealy with only [a-z] | (string) ^ . * ? that will only match strings not containing the sequence "aaa", thus "bu","aa7a"etc. are accepted and "paaaaarot","aaaac","umraaaaaa" and such are not. It's really giving me a headache, so I'd be grateful for help (with short description, so I can understand how the solution works).
You can do it with a negative lookahead -
(?!.*aaa.*)
Not sure how to do it with only the primitives you suggest.
Related
This question already has answers here:
What is the best regular expression to check if a string is a valid URL?
(62 answers)
Closed 5 years ago.
Here is my regex that tries to match a valid URL:
^(https?:\/\/((\b\w[^-][a-zA-Z0-9-]{1,33})\.){1,34}([[a-zA-Z0-9]{1,6})\/?)$
and I've tried to find way to make a simple solution to forbid the use of a hyphen '-' in the beginning and end of a group of letters and numbers.
I'd tried to use \b\w[^-]. But it hasn't helped.
For example, my regex matches this string, but it shouldn't
http://example-.com
I found an answer by myself
^(https?:\/\/([WWW\.]|[www\.])?((([a-zA-Z0-9]|[a-zA-Z0-9][-][a-zA-Z0-9]){1,10})\.){1,33}([[a-zA-Z0-9]{1,6})\/?)$
its just a simple OR [a-zA-Z0-9]|[a-zA-Z0-9][-][a-zA-Z0-9]
If you'll find better solution pls send it :)
This question already has answers here:
escaping question mark in regex javascript
(4 answers)
Closed 7 years ago.
I try to create a simple regex with a question mark based on the following string:
22969152008377?_uw=2884713357351
There should be any number at the beginning, followed by ?_uw= followed by any numbers. I am not able to add question mark to the regex. Thank you for help.
Just escape the question mark like this
\d*\?_uw=\d*
Regex101
This question already has an answer here:
Split regex to extract Strings of contiguous characters
(1 answer)
Closed 8 years ago.
I have following question need reg expert help. I have a string "11122233344456", I need put same digits into a string. For above example, it shall be "111","222","333","444","5","6".
Another example: "223334456111", it shall be "22","333","44","5","6","111".
Would some regex expert help me to find the solution?
You can use this regex:
((\d)\2*)
And grab captured group #1
RegEx Demo
This question already has answers here:
Regular Expressions: Is there an AND operator?
(14 answers)
Closed 8 years ago.
I need to check multiple regexp in one string. Is it possible to check in one regexp? Here is important to find any order of words.
For example I looking for "quick", "jump" "lazy" in the string.
I can check it with OR operator. It working with | (pipe) character. But how can I change the OR to AND ?
I can use this with OR:
/quick|jump|lazy/
But I want to use something like this:
/quick&jump&lazy/
Is there any way?
/(?=.*quick)(?=.*jump)(?=.*lazy)/ is what you're looking for I believe
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Java \ Pattern - how to write a pattern that verifies the lack of a string?
How can I match all strings without the word "authorize" in them via regular expressions? I tried *(authorize){0}* to no avail.
/^(?!.*authorize).*/
This uses a negative lookahead to ensure that the overall pattern will match only if the expression "authorize" cannot match anywhere in the input.