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 7 years ago.
Improve this question
Hi I need regular expression for Email with custom domain only, means I want to exclude:
#live, #hotmail, #outlook, #aol, #yahoo, #rocketmail, #gmail, #gmx.com, #mail.com, #inbox.com, #icloud, #aim, #yandex, #zoho
Use two regex tests for your candidate strings in a single loop.
In the first test, you check for the unwanted domains and skip the string if you get a match:
/^[\w-\._\+%]+#(live|hotmail|outlook|aol|yahoo|rocketmail|gmail|gmx\.com|mail.com|inbox.com|icloud|aim|yandex|zoho)\./
In the second test, you use your standard email regex.
Add the following immediately after the # in your email address pattern:
(?!(?:live|hotmail|outlook|aol|yahoo|rocketmail|gmail|
gmx\.com|mail\.com|inbox\.com|icloud|aim|yandex|zoho)$)
Be sure to use a case-insensitive match.
(Line break added for readability.)
thanks #ikegami and #David my answer I combine between your answer and it's work, most part from David.
Regular expression:
^[\w-\._\+%]+#(?!(live|hotmail|outlook|aol|yahoo|rocketmail|gmail|gmx\.com|mail\.com|inbox\.com|icloud|aim|yandex|zoho)$)(?:[\w-]+\.)+[\w]{2,6}$
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I want to negate the outcome of the regex pattern, so that it should return everything except the regex outcome.
Sample String:
SMTP:test.abc#xyz.com;smtp:test.123#xyz.biz;sip:test.123#xyz.biz
I have written a below regex which gives output as- test.abc#xyz.com
(?<=SMTP:)(.*?)(?=;)
Now i want everything except the above outcome i.e
SMTP:;smtp:test.abc#xyz.biz;sip:test.abc#xyz.biz
I am trying to negate but it is not working.
Any help is much appreciated.
It might be overcomplicated, but if you need multiline matching and a smtp account can be in the beginning of a line, this:
(SMTP:)|(;[^(SMTP)]*)|(^[^(SMTP)]*)
would match:
SMTP:
anything after a ; up until another SMTP
anything at the beginning of a line (no need of ;) up until another SMTP
Have a look at some tests here.
This can break down if an email name contains SMTP in it, but I hope you won t have any.
Another approach is use your matching regex, (?<=\SMTP:)(.*?)(?=\;), and keep deleting what it matches from the string.
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 am having the following String
{'Sample': '#it{tq}', 'Yield': 0.011063753491221462, 'Error': 0}
and I would like to extract the value from 'Sample', that means '#it{tq}'. I tried that using a regular expression: 'Sample':(\s*.+?\s)
but its giving me: '#it{tq}', including that comma at the end. Does anyone know how to erase the comma at the end?
this regular expression should do the job.
regex: 'Sample':\s*('[^']*')
https://regex101.com/r/DL5Ltq/2
how about using this:
'Sample': '(.*?)',
beware that the regex in the accepted answer cannot process the case having single quote escape text inside the capture group like this: {'Sample': '#it'{tq}'}.
If you use (.*?), it greedily process any single character inside two single quote.
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 have string :
/url?q=http://www.bbc.com/indonesia/berita_indonesia&sa=U&ved=0ahUKEwjhqsr6h73OAhVDu48KHTR1AKsQFghDMAs&usg=AFQjCNEv3lNjzDNxPjfpqOtOb0ApNzvCCA
I want to get the result like this :
http://www.bbc.com/indonesia/berita_indonesia
How can I do with using RegEx ?
Thanks
The first capturing group of the following expression will extract the part you want. \?q=([^&]+)
You can extract it with following regex:
/(http:\/\/.+)/
the first (and only) capturing group contains value of url.
Here you can see it in action and adjust for your prefferred language.
EDIT: this pattern will capture whole URL along with following query string. Do you need url with path and without query string?
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have some URLs:
google.com
stack.bing.com
yahoo.com/text/4378
yahoo.com/65456/4378/76576
How to remove URL with more than 2 / characters? After removing, it only has:
google.com
stack.bing.com
How to do it with regular expressions?
In this link http://textmechanic.com/Remove-Lines-Containing.html, it has Enable regular expression search function. So, i want to use regular expression for it.
You can use this regex for matching URLs with less than 2 slashes excluding cases of http://example):
^(?!.*?\/[^\/\n]+\/).+$
RegEx Demo
Or you can inverse the regex for removal:
^(?=.*?\/[^\/\n]+\/).+$
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm searching for a pattern for matching numbers with hyphen at the end like this :
125,000-
1.234,567-
60,000-
Just try with following regex:
/\d[.,\d]*-/
Or even:
/\d([.,]?\d+)*-/
NOTE Aleš Krajník's answer is basically the same as the answer I finally came to, except that his uses non-capturing grouping (as captures are not required)... he should get the votes IMHO as he was first
Note that in the following answer I'm assuming that , comma is the decimal separator, and that the . point is the thousands separator (eg for European numbering).
I believe the following is "correct":
^\d{1,3}(.\d{3})*(,\d+)?-$
This matches eg:
1-
12-
123-
123.456-
123.456.789-
1,0-
1,01-
1,001-
1,0001-
123.456,01-
123.456.789,0001-
etc
But will not match eg
1234-
123,-
123.4-
123.1,001-
123.45-
1..1..1-
1.1.1-
1,1,1-
.,-
etc.
The exact regex should read: \d{1,3}(?:\.\d{3})*(?:,\d+)?-
Try something like this:
[0-9.,]+-
\d{1,3}(?:[,]\d{3})*- takes internationalisation into account. The one below allows strings like 1..9 to match, which really should not.