Regex for email address without characters validation [closed] - regex

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need a regex that will check (if email is like a#b.cc:
email must have # and . (must have both). I refer to the whole string that must contain # and at least one dot.
1st word of email must have 1+ char
the domain name between # and . must be 1+ char
TLD must be 2+ char
I made regex like .+#.+\. but it's not the one, I know. I am bad in regex as I use it so rarely.
Can anyone help me?

It's not clear if you are matching an email in the middle of a paragraph of text, or matching an already extracted string. I am assuming the latter, and anchoring the match to start and end of line...
/^.+#.+\.[^.]{2,}$/
p.s. using regex to validate emails is complex: http://www.regular-expressions.info/email.html

Related

REGEX to get all email addresses from forwarded gmail [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 13 days ago.
Improve this question
I need to get all email addresses from TO, From and cc(Separately) from forwarded email body.
Is this possible with regex?
I am new to regex so don't understand it completely. Can someone help me build this logic?
REGEX LOGIC
You could use [a-zA-Z0-9-_.]+#[a-zA-Z0-9-_.]+ from regex extract email from strings then also add an additional part to it which would allow you to identify CC / To / From separately.
The pattern is 1 or more occurrences of:
a-z: any lowercase letter
A-Z: any uppercase letter
0-9: any digit
-_.: a hyphen, an underscore or a dot
So something like this could work CC:.*[a-zA-Z0-9-_.]+#[a-zA-Z0-9-_.]+. Here I added in CC:.* in the front which makes it so the regex will only grab the line that has CC in it.
.* just means "0 or more of any character"
It's broken down into two parts:
. - a "dot" indicates any character
* - means "0 or more instances of the preceding regex token"
From: What does .* do in regex?
EXAMPLE USE
CC:.*[a-zA-Z0-9-_.]+#[a-zA-Z0-9-_.]+ will grab the line that has a CC: in the front of it.
You would then do a secondary regex of just [a-zA-Z0-9-_.]+#[a-zA-Z0-9-_.]+ with out the CC: identifier to extract each email from the line separately.
Then just do this for each of the three lines you want to capture (to and from).
The regex used is this one: https://regex101.com/r/KIbf1T/1

Extract the required part from same type of URLs in notepad+++ by regex [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
I have a list of URLs from same website. How can I extract a particular part of them using regex in Notepad++?
Here is a part of the URLs:
https://www.example.in/example/MT60B2G8HB-48BA-TR?qs=iLbezkQI%252BsgqYFd1yfooJw%3D%3D
https://www.example.in/example/AT25L128A-MHE-T?qs=IS%252B4QmGtzzoXQyQfwYv36A%3D%3D
Output should be MT60B2G8HB-48BA-TR & AT25L128A-MHE-T from all the similar type of URLs.
A short alternative as usual
Find:^.*/(.*?)\?.*
Replace with:$1
If all URLs have the same url, path up until the last part & do always have GET-parameters (using ?), then you can use this:
"(?<=https://www.example.in/example/)[^?]+"
# match any string that has https://www.example.in/example/ before it until the first ?
If it is optional whether the url has GET-params:
"(?<=https://www.example.in/example/)[^?\s]+"
# match any string that has https://www.example.in/example/ before it until the first ? or whitespace/linebreak
the following will allow you to search for the pattern (in regex mode of course) :
(?<=https://www.example.in/example/).*(?=\?)
(?<=...) is called positive lookbehind and must be a fixed pattern positioned before what you are looking for
(?=...) is called positive lookahead and must be a fixed pattern positioned after what you are looking for (here the first '?' escaped with '\')
If you want to replace the pattern then you can simplify to this.
Find what : https://www.example.in/example/(.*)\?.*
Replace with : $1

How to remove certain prefix using regex [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
My User data can come in any of the following 3 ways -
user="dc\AAA", user="BBB", user=CCCC,
Now, the bottom two I am able to extract it easily but issue comes when user data has an additional prefix of "dc" to it
I am trying to remove that prefix using regex and format all user data in single regex as below, but the unable to do so
user=AAA user=BBB user=CCC
Can someone please help.
This regex should do the work: (?:.*\\)?(.*).
Let's split this regex into parts:
(?: ) - A non-capturing group
.*\\ - Any characters many times, trailing by backslash
? (after the brackets) indicates the data in the brackets may occur once or not at all
(.*) Any characters
Overall - Capturing the data after the backslash if exists
I suggest using this amazing website for trying regex

Match a word from a link [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to work with regex but I'm still not capable of. Asking for your help!
I have links like these:
https://open.spotify.com/track/1Q07lxRM6aQJYtRFzQUtwu?si=LrEcPs3pSxaznY2GLH4V8Q
https://open.spotify.com/album/7lyxArCeA4kkHRiYpnh8eA
open.spotify.com/artist/1mBlZPMpRL8wT9aHBnBBph
I'd like to match the "artist" part in the last link. How can I do it? I thought about using slashes as "separator" than get the string from there but I have no idea.
Assuming you want to extract the top directory name following the
domain name, how about:
import re
url = 'open.spotify.com/artist/1mBlZPMpRL8wT9aHBnBBph'
m = re.search(r'(?:https?://)?[^/]+/([^/]+)', url, re.IGNORECASE)
if m:
print(m.group(1))
Output:
artist
Below, I'm using Python.
It's just build a case insensitive regex that advance any chars (.) with +(1 or more chars) and than use a prefix that occurs always before artist link artist/, finally use ()s to group. Inside ()s uses a class for letters and digits with + suffix (1 or more chars)
.+artist/([a-z1-9]+)
The replaced string it just
/1
The details vary a little bit according to the programming language adopted
See here:

Regex String Mail [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have the following string: test#gmail.com, test#gmail.com <test#gmail.com>, Test Gmail <test#gmail.com>, Test, Gmail <test#gmail.com>.
I would like to use a regex to obtain the following result in an array :
test#gmail.com,
test#gmail.com <test#gmail.com>,
Test Gmail <test#gmail.com>,
Test, Gmail <test#gmail.com>
It is unfortunately not possible to use the comma as separator because it can be included in the string preceding the email (ex : Test, Gmail <test#gmail.com>
((?>(?:\w+#\w+\.\w+)|(?:[^<>\n]+))(?> ?<(?:\w+#\w+\.\w+)>)?)(?:, )?
This will match your sample strings as you have written them.
(?>(?:\w+#\w+\.\w+)|(?:[^<>\n]+)) Match either an email, or some string of characters that does not have <, >, or \n in it, checking first for the email.
(?> ?<(?:\w+#\w+\.\w+)>)? Optionally match another email (with an optional space in front of it).
(?:, )? Optionally match a comma and a space.
Note that this will do nothing to validate whether the captured string is a correctly formatted email; it will only collect strings that look like them, and even then, will only do so only for the format of the specific input you've provided in your example.
Try it here!