How to say in RegExp "contain this too"? [duplicate] - regex

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

Related

Searching for word with lower case and upper case in regex [duplicate]

This question already has answers here:
Using alternation or character class for single character matching?
(3 answers)
Closed 3 years ago.
I have started using regex and am trying to write an expression which searches for a specific word in both upper and lower case.
For example, to search for 'zebra' or 'Zebra', I have created the string \b(z|Z)(ebra)\b.
This works, but is there a more elegant way to do this?
No, there isn't anything much better than you have now. You could drop the parentheses though and simplify it a bit:
\b[Zz]ebra\b or \b([Zz]ebra)\b if you need a capturing group.

Finding Repeated Patterns using a Regular Expression [duplicate]

This question already has answers here:
How to find overlapping matches with a regexp?
(4 answers)
Closed 3 years ago.
I'm trying to extract the repeated pattern from a string.
For example with something like "112112112112" I would want to end up with "112".
I've been having problems where I either end up with "1" or "112112".
The patterns can be of any size.
Here's an example of the kind of expressions I've been playing around with.
^(.+)(?=\1)
There are repeated patterns with different sizes, if 3 would be desired, for instance, we'd use a quantifier for that, such as:
(.{3})(?=\1)
Demo 1
or
(.{3,5})(?=\1)
Demo 2

How to regex part of a string from and to some certain characters [duplicate]

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 3 years ago.
I have the following string and I want to find a proper regex for it, so I can use it in Regular Expression in Jmeter:
DocumentId_123456
The point is that every time the numbers have different length.
so basically I want everything between _ and the end of string.
Please try it, I guess it works in jmeter
DocumentId_(\d+)
Uou can check it here: [https://regex101.com/]

Regex for all strings that contain exactly two occurrences of 'aa'? [duplicate]

This question already has answers here:
Find shortest matches between two strings
(4 answers)
Closed 4 years ago.
This is a simple question of the Theory of Computation.
I don't know nor want the python coded interpretation of this but rather the theoretical answer of the expression.
I have tried my best to figure it out and came up with the below code:
(ab+ba+bb)*. aa.(ab+ba+bb)*.aa.(ab+ba+bb)* + b*.aa.b*.aa.b*
Is it right? Am I forgetting any other case?
Your regex is too complicated and not very flexible (it only works with strings of a and b). A better solution uses negative look-ahead assertions:
^(?:(?!aa).)*aa(?:(?!aa).)*aa(?:(?!aa).)*$
This looks for any length of substring at the start of the string that does not contain aa, then the first aa, and so on.

Regex for not aaa [duplicate]

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.