Regular Expression with specific criteria - regex

Hey everyone, I'm trying to type a regular expression that follows the following format:
someone#somewhere.com or some.one#some.where.com
There are no special characters or numbers permitted for this criteria. I thought I had it down, but I'm a bit rusty with regular expressions and when I tested mine, it failed all across the boards. So far, my regular is expression is:
^[a-zA-Z]+/.?[a-zA-Z]*#[a-zA-Z]+/.?[a-zA-Z]*/.com$
If anyone could help me, it would greatly be appreciated, thanks.

your regex looks good. I think you need to change the / to \ in front of the . .
Additionally, if you don't want someone.#somewhere..com pass your regex, u should change your regex to
^[a-zA-Z]+(\.[a-zA-Z]+)?#[a-zA-Z]+(\.[a-zA-Z]+)?\.com$
(not completely sure about the brackets () though, but i think that should be working)

its a backslash to espace dots. Also put the the parenthesis around the . and what follows otherwise an email like abc.#cde..com would be valid.
^[a-zA-Z]+(\.[a-zA-Z]+)?#[a-zA-Z]+(\.[a-zA-Z]+)?\.com$

It looks mostly OK. Change your / to \ though...
For the second case, I would ensure that if you have a . in the middle, it must be followed by more letters:
^[a-zA-Z]+(\.[a-zA-Z]+)?#[a-zA-Z]+(\.[a-zA-Z]+)?\.com$

Related

Unable to fugure out the Regular Expression of the following

I've been working on Compiler Design lately and found Regular Expression quite tricky.
So I am making a lexical analyzer for which I need lexical specification.
I'm unable to figure out the RE of identifiers (Rules defined below):
Maximum 4 characters
At least 1 Alphabet
What I have already tried:
(letter|digit){4} // I read that we can limit occurrence like this. But in this case, 11aa will also be accepted.
I think I can rewrite the above statement like this as well.
(letter|digit)(letter|digit)(letter|digit)(letter|digit)
Please correct me if I'm wrong and thanks in advance!
The tricky thing about this task is to make sure we have at least one letter.
And that letter could be at any of four positions.
(letter)(letter|digit){0,3} | (letter|digit)(letter)(letter|digit){0,2} | (letter|digit){2}(letter)(letter|digit){0,1} | (letter|digit){3}(letter)

Regex nothing or some options

I am trying to develop a regular expression to extract this: PT~MM:SS~EQP>G-G<EQP from a file.
PT is optional but if it is present it's only valid if it is 1P, 2P, 1EP or 2EP.
So if the example is: 3EP~101:37~POR>4-2<ISL it shouldn't be matching nothing but I am getting 2EP~101:37~POR>4-2<ISL as a match.
So far I've tried this:
(((1|2)P|(1|2)EP)~)?(0{0,1}([0-9]|[1-8][0-9]|9[0-9]|1[01][0-9]|120)):(0*([0-9]|[1-4][0-9]|5[0-9]))~[A-Z]{3}>[0-9]-[0-9]<[A-Z]{3}
Can someone help me?
This might what you are looking for ^(?:[12]E?P)?~?\w+?:\w+?~\w+?>\w-\w<\w{3} (https://regex101.com/r/T8Cy4C/6). Although you did not specified fully what are the requirements for each parts.

regular expression for string with dot del

I am looking for a regular expression for the following string:
SQL Err 100 on \TEST1.$PROD01.TEST.XYZ562
I want to search for anything with TEST*.$PROD*.TEST.XYZ*.
Can anyone help with the regular expression?
Basic effort was required, you could just tried it yourself and, I believe, find an answer on your own! For future needs, try site regex101.com, it helps to work with regulars.
So, you need to find a string containing TEST, then something, then . then $PROD value, again anything, and .TEST.XYZ, and finally anything, where $PROD is, as I understand, a variable without special characters (as [](){}.^\).
So, you get that:
TEST[^.]*\.<$PROD value should go here>[^.]*\.TEST\.XYZ
That should be enough. You will need to supstitude variable $PROD on your own, but I don't know your language, so I can't help with that part. Maybe something like this:
"TEST[^.]*\." + $PROD + "[^.]*\.TEST\.XYZ"

Can someone tell me the regular expression for this?

I am working with regular expressions, I need to create an expression for validating strings against the following scenario:
Solution.<word1|word2|word3>.<word4|word5>.anyword.(any word containing proj in it)
I tried
Solution.\b(word1|word2|word3)\b.\b(word4|word5)\b.(.*).\b(.*proj)\b
But this allows strings like Solution.word1.word4.blabla.blabla.csproj, meaning it allows anything before the proj because of the .*.
Can someone help me with this??
Looks like you need this regex:
Solution\.(word1|word2|word3)\.(word4|word5)\.([^.]+)\..*?\bproj\b
RegEx Demo
You might want to try (need to escape the . and allow capturing group to have chars except .):
Solution\.\b(word1|word2|word3)\b\.\b(word4|word5)\b\.([^\.]*)\.\b([^\.]*proj)\b
It's hard to consider the actual strings you want to allow without more clarification.
You can try the following regular expression.
Solution\.word[123]\.word[45]\.\w+\.\w*proj\b

Matching Any Word Regex

I would like to remove hundreds on onmouseover events from my code. the evt all pass different variables and I want to be able to use dreamwaever to find and replace all the strings with nothing.
Here is an example
onmouseover="parent.mv_mapTipOver(evt,'Wilson');"
onmouseover="parent.mv_mapTipOver(evt,'Harris');"
onmouseover="parent.mv_mapTipOver(evt,'Walker');"
I want to run a search that will identify all of these and replace/remove them.
I have tried seemingly infinite permutations of things like:
onmouseover="parent.mv_mapTipOver(evt,'[^']');"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,[^']);"
or
onmouseover="parent.mv_mapTipOver(evt,'[^']+');"
And many more. I cannot find the regular expression that will work.
Any/all help would be appreciated.
Thanks a ton!
"." and "(" have special meaning in regular expressions, so you need to escape them:
onmouseover="parent\.mv_mapTipOver\(evt,'[^']+'\);"
I'm not sure if this is correct dreamweaver regex syntax, but this stuff is standard enough.
Try this one:
onmouseover="parent\.mv_mapTipOver\(evt,'.+?'\);"
And see it in action here.
When using reg expressions you have to be very careful about how you handle white space. For example the following piece of code will not get caught by most of the reg expressions mentioned so far because of the space after the comma and equals sign, despite the fact that it is most likely valid syntax in the language you are using.
onmouseover= "parent.mv_mapTipOver(evt, 'Walker');"
In order to create regexp that ignore white space you must insert /s* everywhere in the regexp that white space might occur.
The following regexp should work even if there is additional white space in your code.
onmouseover\s*=\s*"parent\.mv_mapTipOver\(\s*evt\s*,\s*'[A-Za-z]+'\s*\);"