trying to Exclude Strings from my Regex Search - regex

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).*).*$

Related

Using RegEx with Alteryx to replace string

I have a simple issue: Using Alteryx, I want to take a string, match a certain pattern and return the matched pattern.
This is my current approach:
Regex_replace("CP:ConsumerProducts&Retail</td><td><strong><fontcl","[^\<]+","$1")
According to various sources and tools like regex101, the first matched sequence should be "CP:ConsumerProducts&Retail". However, Alteryx returns
<<<<
Alteryx uses the Perl RegEx Syntax (https://help.alteryx.com/2018.2/boost/syntax_perl.html), therefore, it should have no problem with the pattern itself.
I believe I am missing something obvious but I cannot figure it out.
I have received a reply through a different forum. A solution that works for me is to use the following pattern: ([^\<]+).*
You can try the following workflow:

REGEX - Conditional replacement stopping to match when I choose the new string

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

Issues with RegEx

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).*|)|^.*).*$

REGEX: excluding a string from a pattern that is already excluding particular characters

I'm trying to write a regular expression to use to validate a url path. We orginally had the pattern: [^#\?:]+ which would grab everything up until the first ?, : or # from the path.
We now want to also exclude the string 'index.cfm'.
I can't work out how to include this though. I've had a look at lookarounds but I can't seem to work out how to use it in conjunction with the pattern we already have.
EDIT: Here's an edited solution according to your comment.
^.*?(?=[#?:]|index\.cfm|$)
Here's a demo using the site you mentioned: http://regexr.com?31rk9.
should work for you
^(?P<url>[^#?:](?!index\.cfm))+

Notepad++ replace with reg expression?

I have a big list with links and other date in it. I want to filter out all the data and have a list with just the links.
Example of the current list:
32,2012-01-04 06:44:44,http://link.com/link
33,2012-01-04 06:44:45,http://link.com/link,{Text|textext|text},http://link.com/link|http://link.com/link|http://link.com/link
Notepad++ offers find replace functionality using RegEx. You can access this feature by using Ctrl+H.
If you're actually asking for a regular expression to do this, you can use something like this to match URLs:
\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))
which I found here.
Additionally you can test out changes to your regex easily at http://gskinner.com/RegExr/
Using the input you provided, here's a pattern you can use on http://www.regexr.com/
You'll need to make sure the global (/g) flag is on
Expression:
.*?(http.*?)[,|\n]
Input:
32,2012-01-04 06:44:44,http://link.com/link1
33,2012-01-04 06:44:45,http://link.com/link2,{Text|textext|text},http://link.com/link3|http://link.com/link4|http://link.com/link5
Substitution:
$1\n
Output:
http://link.com/link1
http://link.com/link2
http://link.com/link3
http://link.com/link4
http://link.com/link5