regex code domain sort

i use this code: (.+?@(yahoo|xplorer|link).(?:ca|net|com))

results are:
asd@yahoo.com
asdsad@xplorer.ca
adas@earhtlink.net
asdsfsd@linkin.com


as you can see here appear: earthlink.net and also linkin.com  etc i want only @link.com
only that words MATCH CASE and not other extensions
maurice cristenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NerdsOfTechTechnology ScientistCommented:
If you want just @link.com emails, use:
(.+?@link\.com)

Open in new window


1st Capturing Group (.+?@link\.com)

.+? matches any character (except for line terminators)

+? Quantifier — Matches between one and unlimited times, as few times as possible, expanding as needed (lazy)

@link matches the characters @link literally (case sensitive)

\. matches the character . literally (case sensitive)

com matches the characters com literally (case sensitive)

I recommend making it case insensitive:
/(.+?@link\.com)/i

Open in new window


i modifier: insensitive. Case insensitive match
0
maurice cristenAuthor Commented:
i want also this, all this filetr at the same time :
ciaccess.com
cruzinternet.com
davincibb.net
dewinton.ca
efirehose.net
everus.ca
figment.ca
highriver.net
highspeedfx.net
hotlinkwireless.ca
hotlinkwireless.com
hsfx.ca
imagewireless.ca
lincsat.com
link.ca
mycanopy.net
myipplus.net
okotoks.net
ourbusiness.ca
ourmail.ca

Open in new window

0
NerdsOfTechTechnology ScientistCommented:
Please reply to the thread.

this is the lsit i want toe xtract, all at the same time:
xplornet.com
xplornet.ca
aernet.ca
airsurfer.ca
albertahighspeed.ca
albertahighspeed.com
albertahighspeed.net
bears-paw.ca
canopycanada.net
ciaccess.com
cruzinternet.com
davincibb.net
dewinton.ca
efirehose.net
everus.ca
figment.ca
highriver.net
highspeedfx.net
hotlinkwireless.ca
hotlinkwireless.com
hsfx.ca
imagewireless.ca
lincsat.com
link.ca
mycanopy.net
myipplus.net
okotoks.net
ourbusiness.ca
ourmail.ca
pcc-inet.ca
platinum.ca
platinumcommunications.net
priddis.ca
ripnet.com
rttinc.com
skyvelocity.ca
southkent.net
spring-bank.ca
talkwireless.ca
tbwifi.ca
wildroseinternet.ca
wildrosenet.ca
wildrosenetworks.ca
yourlink.ca


i tried to use this:
(.+?@aernet|airsurfer|albertahighspeed|bears-paw|canopycanada|ciaccess|cruzinternet|davincibb|dewinton|efirehose|everus|figment|highriver|highspeedfx|hotlinkwireless|hsfx|imagewireless|lincsat|link|mycanopy|myipplus|okotoks|ourbusiness|ourmail|pcc-inet|platinum|platinumcommunications|priddis|ripnet|rttinc|skyvelocity|southkent|spring-bank|talkwireless|tbwifi|wildroseinternet|wildrosenet|wildrosenetworks|yourlink).(?:ca|com|net))

but i have a problem here,let's take as example:@yourlink.com
output look like this:

sds@yourlink.com
asdas@earthlink.com
sadsa@link.net

you see?
i want only --> yourlink.com

/(.+?@)(aernet|airsurfer|albertahighspeed|bears-paw|canopycanada|ciaccess|cruzinternet|davincibb|dewinton|efirehose|everus|figment|highriver|highspeedfx|hotlinkwireless|hsfx|imagewireless|lincsat|link|mycanopy|myipplus|okotoks|ourbusiness|ourmail|pcc-inet|platinum|platinumcommunications|priddis|ripnet|rttinc|skyvelocity|southkent|spring-bank|talkwireless|tbwifi|wildroseinternet|wildrosenet|wildrosenetworks|yourlink)\.(ca|com|net)/i

Open in new window

0
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

NerdsOfTechTechnology ScientistCommented:
Now the REGEX I gave previously, is for (your list) and (ca, com, or net wildcard). If you want more restrictive filtering, which is always best, use EXACT domains in the 2nd capture area:

/(.+?@)(ciaccess\.com|cruzinternet\.com|davincibb\.net|dewinton\.ca|efirehose\.net|everus\.ca|figment\.ca|highriver\.net|highspeedfx\.net|hotlinkwireless(\.ca|\.com)|hsfx\.ca|imagewireless\.ca|lincsat\.com|link\.ca|mycanopy\.net|myipplus\.net|okotoks\.net|ourbusiness\.ca|ourmail\.ca)/i

Open in new window


This will match link.ca but not link.com
0
maurice cristenAuthor Commented:
this code not working:

/(.+?@)(ciaccess\.com|cruzinternet\.com|davincibb\.net|dewinton\.ca|efirehose\.net|everus\.ca|figment\.ca|highriver\.net|highspeedfx\.net|hotlinkwireless(\.ca|\.com)|hsfx\.ca|imagewireless\.ca|lincsat\.com|link\.ca|mycanopy\.net|myipplus\.net|okotoks\.net|ourbusiness\.ca|ourmail\.ca)/i

Open in new window

0
NerdsOfTechTechnology ScientistCommented:
Which programming language are you using?

Should work for PHP, PCRE, Python, Golang and JavaScript

I'm showing it working:

https://www.regextester.com/?fam=99775
0
NerdsOfTechTechnology ScientistCommented:
That program doesn't use normal REGEX parsing with 'flags' so you will have to CASE tab 'convert word to lowercase' first, load the lower case text file in, then run the REGEX tab (retain pattern within word if you are keeping just the found emails; or remove if you are eliminating them):

((.+?@)(ciaccess\.com|cruzinternet\.com|davincibb\.net|dewinton\.ca|efirehose\.net|everus\.ca|figment\.ca|highriver\.net|highspeedfx\.net|hotlinkwireless(\.ca|\.com)|hsfx\.ca|imagewireless\.ca|lincsat\.com|link\.ca|mycanopy\.net|myipplus\.net|okotoks\.net|ourbusiness\.ca|ourmail\.ca))

Open in new window


Mission accomplished!
test.txt
test---Lower-Case.txt
test---Lower-Case---Regex-Retain-Fro.txt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
maurice cristenAuthor Commented:
yes,thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.