regular expression usage with [word1][wor2] [closed] - regex

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.

Related

Cannot use ^(hat) in parentheses regular expression [closed]

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 days ago.
Improve this question
I tried to capture file extension: get .m3u8 if my filename is ABC.m3u8 for example.
The regular expression I use:
\w+(^\.[A-Za-z0-9]+)
I cannot get the result as my expected if I don't remove hat(^) character. Please tell me why, thanks.
There are two issues with \w+(^\.[A-Za-z0-9]+) :
^ would match the beginning of the string
not anchoring it at the end would give false captures, such as .foo for abc.foo.mp3
Here is the corrected regex:
^[\w+\.]+(\.[A-Za-z0-9]+)$
Or simply:
(\.[A-Za-z0-9]+)$
Learn more about regex: https://twiki.org/cgi-bin/view/Codev/TWikiPresentation2018x10x14Regex
^means match the beginning of a line, rather than beginning with ., so adding ^ will not match.

Is there a Notepad++ RegEx to remove everything but digits and spaces? [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
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

How to process search results using regex? [closed]

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.

Need a regular expression to keep domain [closed]

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]+\/).+$

Regex of changing numbers [closed]

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 9 years ago.
Improve this question
I would use regex to select one changing number
For example in the following example I would select 12090343 that I could change
I use:
preg_match (/(?<=Dossier.N..)(.*)(?=-)/)
It works but it's not so clean I think because the number of spaces could change and so it will not detect the number any more
Dossier N° 11110144-001 Pvt du : 03/09/2013 à 7:16
It looks fine, but you could slightly clean it up by .not grouping the number and making it match digits:
(?<=Dossier.{0,3}N.{0,3})\d+(?=-)
Most regex engines can't handle look behinds of arbitrary length, so rather than using the simpler (but unbounded) expression \s*, you must use a limited length expression like \s{0,3} to allow "some" whitespace.
You can try the following expression:
/Dossier[^0-9]*\K([0-9]*)(?=-)/
Regex101 Demo