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.
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 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
The problem in Akeneo seems to be that simple regex combinations not working. I think the functionality (a single or group regex combination) is not integrated/implemented proper in Akeneo. If there is anybody out there who knows a trick to do a regex combination please let me know.
Tried to figure out how to make regex with | OR working in Akeneo "attributes".
the simple Example not working either a syntax error or no matching in Akeneo:
find this "323"
or find "123456"
\d{3}|\d{6}
Can anybody help?
According to the documentation, you need to use regex literal notation, and anchor the match both at the start and end of the string (so, add a grouping):
/^(\d{6}|\d{3})$/
Here, / are regex delimiters, ^ matches the start of string, (...) is a capturing group that contains two alternatives, six digits or three digits, and then end of string anchor, $, follows.
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 6 years ago.
Improve this question
I have this regex string:
("prodcssstart.*prodcssend","xx")
and my file like this:
prodcssstart
<!--<link href="content/bundles/css.min.css" rel="stylesheet" />-->
prodcssend
But when I run it then it fails to find the expression.
Can someone suggest what I might be doing wrong, I've simplified it so much but I am thinking maybe there is a problem with the .* that I use to match everything. Any help would be much appreciated.
First of all, you can't parse HTML with regex.
But in your case the problem is most likely caused by newlines, because by default the dot doesn't match the newline. You need to pass the proper switch to disable this (e.g. re.DOTALL in Python and s in Perl).
You could come up with a tempered greedy token solution:
prodcssstart
(?:(?!prodcssend).)*
prodcssend
Breakdown:
look for prodcssstart
match any character as long as it is not followed by prodcssend
match prodcssend
See a demo on regex101.com (mind the different modifiers!).
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}$
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
How to process search results using regex?
E.g., I have a file with many strings like AB.
I want to get: 'AB'.
The letters always differ.
So I would search for the regex pattern ^\w+\n and want to use the search result, let me use '$#' to depict it, to get '$#'.
Regex:
(?<=:)([^,]+)
REplacement string:
'$1'
DEMO
Just to clarify: You want 71:A,72:BC,73:ABD to become 71:'A',72:'BC',73:'ABD' right?
Do a find/replace in whatever language or program you are using:
Find: (\w+)
Replace: '$1'
This finds ANY multi-letter string in your file and puts ' around it. if you only want to do the ones with [number:string] you will need to use a look-ahead like (?=\d+:) in front of the (\w+). So the whole Find would then look like (?=\d+:)(\w+), similar to what Avinash Raj has posted.
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 hate to ask specific question, but i need the regex code for matching strings like :
{block any_single_word_here}
Anything Here
{/block}
Your original query is very close, albeit a little verbose. It can be shortened to:
/{block (.+?)}(.+?){\/block}/
(The ? modifier stops the + from being "greedy", so you don't have to explicitly stop the match at the next } or {.)
Next you have to consider that . won't match newlines by default. You can change this with the /s flag:
/{block (.+?)}(.+?){\/block}/s
Here's a demo.
And here's the documentation from man perlre:
s
Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which normally it would not match.
In javascript (added escape to end of lines in original string) I added a \s* (zero or more spaces) to your regex and it outputs a match for any_single_word_here and Anything Here fine...
alert( "{block any_single_word_here}\
Anything Here\
{/block}".match(/\{block ([^\}]+)\}\s*([^\{]+)?\{\/block}/) )
For simpler regex, remove the unneccessary escaping, and just capture with . rather than complex [^\}]
/{block (.+)}\s*(.+){\/block}/
Does this do the job?
/\{block \w+\}\r?\n.*?\r?\n\{\/block\}/i