This question already has answers here:
MongoDB reverse regex
(2 answers)
Closed 4 years ago.
Ok, I know, there was a similar question on this site, but it's 2 years old, so the situation can be different now.
I have some documents with stored regular expressions, just like this:
{
_id: ObjectId("aaaaaaaaaaaaaaaaaaaaaaaa"),
regex: /^some_regex.*$/
}
So I've got an input string and I need to find all the documents, where regex matches the string.
The only way to solve the problem I know, is $where operator usage, but it's not a solution I'm looking for, because $where is very, very slow. Is there another way?
There is no such an opportunity in Mongo. $where operator is the only way to perform this server-side.
Related
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/]
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.
This question already has answers here:
Regex to match repeated characters
(3 answers)
Closed 6 years ago.
I am having a hard time with Go's regex. It seems it's different than other language, can someone help me on this.
Obj. I want MustCompile to find all repeated characters in the string.
APPLE (where P's repeating)
re := regexp.MustCompile("(\\w)\\${1}\\+")
Above is what I have tried but didn't work at all. Basically I wanted to do:
([A-Za-z])\1+
Can someone tell me what I am doing wrong?
Example below:
https://play.golang.org/p/DeuaIva968
Apparently Golang doesn't supposed back referencing due to efficiency. :(
Thank you everyone for your help.
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:
Using Regex to generate Strings rather than match them
(12 answers)
Reverse regular expression, create string from regex
(1 answer)
Closed 9 years ago.
Or "How can I RegEx in reverse?"
specifically I want to take a regex such as wks[0-9][0-9][0-9]
and create a list such as wks001,wks002,wks003, etc
I know the easiest way in this example would be to simply increment the number through addition, but say I want it to be even more sophisticated later on such as [0-9abc] I'd like to use a more sophisticated tool.
preferable would be some windows capable scripting tech, such as vbscript/powershell but I'm open to other alternatives. I guess I kind of thought this might be something that is done all the time by random number generators and such and would be a programming staple, but I lack the understanding to phrase it correctly I think.