This question already has answers here:
My regex is matching too much. How do I make it stop? [duplicate]
(5 answers)
Closed 6 years ago.
Here's my current setup:
(image showing regexr-highlighted strings)
My regexp match is Skript\.register(effect|expression|event|condition)\((.*)\)\;
Basically, I want to match all methods from a source code file that start with Skript.registerwhatever.( and end with );, but the problem is the code can go multiline. If I change (.*) to ([\s\S]*), it completely wrecks and matches everything until the very last );.
You need a lazy quanitfier: *?
\(([\s\S]*?)\)
And if your string contains nested parenthesis:
(?'parens'\((?:[^\(]|\g'parens')*?\))
You need to escape parenthesis in regex because they are reserved symbols. Try \(.*\)
Related
This question already has answers here:
How to match multiple occurrences of a substring
(3 answers)
Regex match sequence more than once
(2 answers)
Closed 2 years ago.
I have problem with regular expression.
https://regexr.com/505i2
Somehow it find only one :heart: but it should find these words when it's beetwen : character.
So in this case it should be: :heart: , :smile: , :smile: , :heart:
Please help.
You are missing the global flag:
/\:([a-zA-Z]+\w)\:/g
You can just tick it from the flags button.
The global flag means that you want to mark all occurrences of your pattern. Without it, you just get the first match.
This question already has answers here:
Regular expression to get a string between two strings in Javascript
(13 answers)
Closed 3 years ago.
Link Regex101
I am using (FD.*?)FD however I am missing every second expression - see regex. Any ideas?
The trailing "FD" in your regex matches the "FD" in the input that starts the next "item" in the input text, so the entire next "item" is skipped, until it finds another "FD".
In a case like this, instead of specify .* followed by the pattern that starts the next item, you typically want to specify anything not including a pattern of FD.
This question already has answers here:
Does regex lookahead affect subsequent match?
(2 answers)
Closed 4 years ago.
I have currently a pattern match in a query like this
if(upper(email_omni_code_mini) like '%TRAVEL%' and upper(email_omni_code_mini) NOT like '%TRAVEL%ENS%',...,...)
I want to change this to a single pattern match but this won't work
TRAVEL(?!ENS) as ENS is not immediately following.
Is there a way to solve this easily.
Any help is appreciated.
If there are other chars in between, insert .* before ENS:
TRAVEL(?!.*ENS)
It will now match TRAVEL that is not immediately followed with any 0+ chars as many as possible followed with ENS substring.
See the regex demo.
This question already has answers here:
Regex: match everything but a specific pattern
(6 answers)
Closed 4 years ago.
I am trying to find all strings not ending with the sequence -6X.
What i'm trying to do is compare the value of an xml tag with a sequence.
If it matches then do some stuff.
However I am unable to do so. I want to achieve this without any lookaheads or lookbehinds.
I've tried using .*[^-6X]
However this does not work for strings ending in - or -5 .
I want to ignore strings ending in -6X only and every other pattern should work.
Thanks in advance for your help
This matches Strings NOT ending with -6X:
.*?([^-]..|.[^6].|..[^X])$
https://regex101.com/r/omwkQ3/2
This question already has answers here:
Zero-Length regexes and infinite matches?
(2 answers)
Closed 6 years ago.
If you try on http://regexr.com/ the regex \t you get all the single tabs. But if you try \t* you get only on the beginning of the first line. Why?
If you use \t* only, then you trying to match nothing, one or more tabs. Nothing in regexp will match anything, so it won't work.
If you need to find one or more tabs, use \t+ instead.
To make your regexp work on all lines, use global setting. There is an example: http://regexr.com/3db4i