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.
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
Is there a RegEx to remove everything but digits and spaces in Notepad++?
I know there is one that removes only digits but i dont need that.
PS: I do not want the lines to be removed
Example:
11234123 alex-james
1412412 mmafsmasdas
After regex:
11234123
1412412
As the pattern use [^\d ]+. Almost what Poul Bak proposed, but change * into +, i.e. the sequence of chars to match should be non-empty.
There is no point in searching for an empty string and replace it with another empty string.
correction:
try this:
([^0-9| ]+)
this will surely work!!!
open the file in notepad++ press CTRL+H check the box with search mode regular expression and put in the above regex and click replace all
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 2 years ago.
Improve this question
I have a pattern like [word1][wor2]. I want to replace to {#link word2|word1}, word1, word2 could be anything.
I am very bad on using regular expression. Could anyone help me use regular expression match the pattern and replace to new pattern.
Thanks in advance.
Try the following find and replace, in regex mode:
Find: \[([^\]]+)\]\[([^\]]+)\]
Replace: {#link $2|$1}
Demo
The uses the approach of capturing the two adjacent word in square brackets, and then replacing with the text you want.
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 5 years ago.
Improve this question
guys...
I have a big HTML, and i want to take all links that start with
"https://exampledomain.com/category/" and delete the rest, the HTML have links like "https://exampledomain.com/edit/..." "https://exampledomain.com/view/...", have tags, texts, and i want to delete all but no "https://exampledomain.com/category/.../"
the final result must be like this:
https://www.exampledomain/category/presents/
https://www.exampledomain/category/books/
https://www.exampledomain/category/clothes/
https://www.exampledomain/category/bags/
Any ideas?
Thanks! :)
As Alex proposed, i've used search and replace to sepparate the links alone in a line (using extended \n)...
Search: (https://www.exampledomain/category/[^"]*)
To match all link until (") (end of href="url")
Replace with: \n\n\1\n\n
When its done, i've used notepad++ " CTFL + F > Mark " to select all lines that contains
https://www.exampledomain/category/
then, removed no marked lines... Using Menu > search > markers > remove no selected lines...
Thanks! :D
You could use this:
Wrap around:: yes
Find: .*?"(https://www.exampledomain/category/.*?)"|.*
Replace: \1\n
Regular expression: yes
. matches newline: yes
Click Replace All
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!).