I have a lot of developer's name like this:
/Ramon/ /Cesar/ /Murilo/ /Tiago/
I would like to apply a conditional regex to replace every name with just its first letter.
So when it matches /Ramon/ it would become /r/, /Cesar/ turn into /c/...
I'm trying to achive it here: https://regex101.com/r/rTlS1k/3
With no success.
Appreciate any help.
Thanks.
Assuming you are using PCRE based on your regex101, then search for:
/\/(\w)[^\/]+\//g
and replace with
/\L\1/
As seen here: https://regex101.com/r/ZDQlEY/1
Related
I'm using the following expression to filter Oracle Java vulnerabilities from a list. This works just fine:
^(?!.*Oracle Java.*).*$
I'm having a tough time adding another string to exclude.
I got the expression from an earlier question here:
Regular Expression to exclude set of Keywords
I've tried all the examples from this link but the answer Tim gave was the only one that worked for me.
Does anyone know how I could add another string to this?
^(?!.*Oracle Java.*).*$
You can use regex alternation inside the lookahead:
^(?!.*(Oracle Java|excluded1|excluded2).*).*$
I'm using TinyTinyRSS and want to organize my articles with the implemented filter feature that supports regular expressions. Normally, I filter for words like star and everything that contains star is found. But I also want to exclude certain words like started, starshine or seastar.
F.i, my Google query would look like this: star -started|starshine|seastar
So what's the appropriate command in RegExp?
Thanks in advance!
You can make use of word boundaries:
\bstar\b
Will look for the word 'star' and nothing else, meaning nothing like custard or stars.
If you want to avoid matching only those and if you are using a regex engine which supports lookarounds fully, you can perhaps use:
(?<!sea)star(?!ted|shine)
I am trying to make an if-then-else statement using RegEx. I want to match the text if it contains Monty and also contains Python. Also the text should get matched if Monty is not present in the text.
RegEx
(?(?=Monty)(?(?=Python).*|)|^.*).*$
Kindly help!
How about this:
(^(?!.*Monty(?!.*Python.*).*).*$|^.*Python.*Monty.*$)
This passes my tests, but let me know if it works for you.
I am not versed in lookahead regex but just tried to build the regex from what I understood from above description. Check the link to see if this is what you are trying to do.
try this instead
((?=Monty)((?=Python).*|)|^.*).*$
I have to deal with a problem and maybe you can help.
I took over a Website with a lot of code and would like to have it run on PHP 5.4.
But there are a LOT of statement's like this:
if($arrayname['keyname']>"") ....
I would like to replace them all with:
if(!empty($arrayname['keyname'])) ....
Doing it manually will take forever :-(
Do you know how to use Dreamweaver's CS5 search & replace with RegEx capabilites - unfortunately my RegEx knwoledge is limited.
Of course the regex must be "variable, as the arrayname and the keyname always changes.
Any help on finding the correct RegEx Stamtent is HIGHLY appreciated .
Regex to find all occurrences of if($arrayname['keyname']>""), whatever arrayname and keyname are, if only letters :
if\\(\\$[a-zA-Z]*\\[\'[a-zA-Z]*\'\\]>\"\"\\)
You'll have to find how to use BackReferences in Dreamweaver. If it uses standard Regex, then use the tutorial in the link, it will be of great help for you.
To complete and close this question:
In Dreamweaver search for (Regex Search in Code):
if\(\$(\w+)\[['"](\w+)['"]\]>""\)
Replace by:
if(!empty($$1['$2']))
Hopefully someone can help me out. Been all over google now.
I'm doing some zone-ocr of documents, and want to extract some text with regex. It is always like this:
"Til: Name Name Name org.nr 12323123".
I want to extract the name-part, it can be 1-4 names, but "Til:" and "org.nr" is always before and after.
Anyone?
If you can't use capturing groups (check your documentation) you can try this:
(?<=Til:).*?(?=org\.nr)
This solution is using look behind and lookahead assertions, but those are not supported from every regex flavour. If they are working, this regex will return only the part you want, because the parts in the assertions are not matched, it checks only if the patterns in the assertions are there.
Use the pattern:
Til:(.*)org\.nr
Then take the second group to get the content between the parenthesis.