Regex to search multiple strings spam - regex

I have a problem we are receiving many spam emails with the following strings:
(vi#gra, v1agra, v1#gra, v!#gr#)
I already create several regular expressions for each of the words but I don't know how to join my regular expressions to just one
^v[0-9]+agra$

You may use the following regex pattern:
v[i1!][a#]gr[a#]
Demo
Note that this pattern also matches viagra, in addition to the four viagra variants which you gave in your question.

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 to highlight Strings in code

I'm developing a small code editor and I would like to match Strings so I can highlight them a different color.
Example:
myvar = array('VOLVO', 'TOYOTA')
Using regex expression \'.*\' I get one match 'VOLVO', 'TOYOTA'
However, what I want are two matches: 'VOLVO' and 'TOYOTA'
Is this possible to achieve with a single regex expression?
Someone did suggest the following expression:
\'[^\']*\'
Which in fact solves my problem: I get two matches, one for 'VOLVO' and one for 'TOYOTA'.

PCRE Regex to RE2 Regex

In a previous question, I got the answer on a regular expression to accept all email addresses from a certain domain except two from the same domain.
e.g. :-
BAD:
test#testdomain.com
tes2#testdomain.com
GOOD:
notest#testdomain.com
test23#testdomain.com
Here is the regular expression from that answer:
^(?!test#|tes2#)[A-Za-z0-9._%+-]+#testdomain\.com$
However, for my application, I specifically need RE2 regex to be able to use this.
What is the steps I should take to convert this PCRE expression to RE2 type?

Google Analytics Regular Expressions

Kinda new to Rgeluar expressions and for the benefit of learning wanted to know how to do the following on one line:
page matching regular expression: .pdf/$
and page containing "somestring"
and page excluding "someotherstring"
I can obtain my desired output using the 3 rules above. My question is can I put all into one line using regular expression? So the first line would be something like:
page matching reg exp: .pdf/$ somestring+ (then regex for does not contain in GA) someotherstring
Is it possible to put all in a oner?
Lookahead will help you to match multiple independent things in one expression, and even allows to require non-matching. In your case:
/^(?=.*somestring)(?!.*someotherstring).*\.pdf$/

Regular Expressions with conditions

I have a string that looks like:
this is a string [[and]] it is [[awesome|amazing]]
I have the following regular expression so far:
(?<mygroup>(?<=\[\[).+?(?=\]\]))
I am basically trying to capture everything inside the brackets. However, I need to add another condition that says: If the matched result contains a pipe delimiter then only return the word to the right of the pipe delimiter. If there is no pipe then just return everything inside the brackets.
The parsing result I am looking for given the example above should look like:
and
amazing
Any input is appreciated.
(?<mygroup>(?<=\[\[)([^|\]]*|)?([^|]+?)(?=\]\]))
You could use this regex:
(?<=\[\[[^\]]*?)(?!\w+\|)\w+(?=\]\])
it matches both and and amazing words in your test example. You could check it out, I created a test app on Ideone.
From the regex info page:
The tremendous power and expressivity
of modern regular expressions can
seduce the gullible — or the foolhardy
— into trying to use regexes on every
string‐related task they come across.
My advice: Just grab what is between the brackets and parse it after.
Regular expressions are not the answer to everything. May those who follow after you be spared from deciphering the regex you come up with.