Using notepad++ to find and replace some variables but also add some items.
I need
<date>20140427</date>
replaced with
<previously-shown start="2014-04-27"></previously-shown>
So far I have
Find what:
<date>\d{4}\d{2}\d{2}</date>
replace with:
{<previously-shown start="} + \3-\2-\1"></previously-shown>
Add capturing groups to the pattern and change the order of the backreferences in the replacement:
Find What: <date>(\d{4})(\d{2})(\d{2})</date>
Replace With: <previously-shown start="$1-$2-$3"></previously-shown>
See the regex demo.
How to find the text between the second and fourth slashes in a path like /folder/subfolder-1/subfolder-2/subfolder-3? I’m trying to replace this with something like /folder/new-folder/subfolder-3.
The most important for me is to be able to find the part after the n-th slash.
I tried the regex /((.*?)/){3}, but it doesn’t work.
Using Match resetter \K meta-character you are able to do it in a simpler way.
Find:
/.*?/\K(.*?/){2}
Replace with:
new-folder/
One way you could to it is by using this string in the pattern to replace
(/.+?)(/.+?){2}(/\S+)
And use this one in your pattern to replace it with
$1/new-folder$3
From your string:
/folder/subfolder-1/subfolder-2/subfolder-3
(/.+?) will match /folder as $1
(/.+?){2} will match /subfolder-1/subfolder-2 as $2 (not used)
(/\S+) will match everything that isn't a space, in this case/subfolder-3 as $3
Leaving you room to insert your new-folder in-between.
How can I just mark till the slash?
Find what: (/[^/]+/)[^/]+/[^/]+
Replace with: $1new-folder
To find text between second and forth slash you can use the regex ^(/[^/]*/)([^/]*/[^/]*) then you can reference to the text between slashes with \2 when replacing the text.
To keep the text before the slashes you can enter something like \1myNewTextBetweenSlashes2and4.
In notepad++ Find by this:
(/[^/]+)(?:/[^/]+/[^/]+/)(.*)
And Replace by this:
\1\/new-folder/\2
Make sure that: .matches newline is not checked
{2} indicates 2 levels after first level will be repalced by new-folder
Find:
(\/.*?\/)(.*?\/){2}(.*)
Replace:
$1new-folder/$3
Demo: https://regex101.com/r/XIA3IN/3
I have the following text in NotePad++, I am trying to write a RegEx to find and replace with the following.
Find: #,##/ (Look for the pattern 2,10/)
Replace: #\r (at the comma replace with a new line, so the date starts on a new line)
11/02/2016,18,54,61,13,37,05,2,10/29/2016,42,48,20,21,19,23,3,10/26/2016,48,56,02,16,03,24,2,10/22/2016,01,55,33,28,56,22,2,10/19/2016,43,63,16,38,10,23,2,10/15/2016,64,49,57,23,67,20,2,10/12/2016,34,44,30,16,37,16,2,
You seem to be looking for capturing groups: capture the different parts that should get split with a newline and use backreferences in the replacement pattern.
Search: (\d,)(\d+/)
Replace: $1\n$2
See the NPP screenshot:
This regex will work: (\d),(\d\d/)
Replace with: \1\r\2
Result example:
I would like to replace the single quotes from the number in the below text.
('28','Harry Potter');
The output required is
(28,'Harry Potter');
What kind of regex is required to remove the quotes in Word/notepad++ ?
How about:
Ctrl+H
Find what: '(\d+)'
Replace with: $1
Then click on Replace all
This will remove all single quotes arround digits.
For Word 2010:
Use
Find what:
([0-9]{2,})
replace with:
\1
I'm trying to find and replace a string into the wanted string, but can't get it to work.
For example:
1777: '23.5R25 Bridgestone VLT **',
Should be:
1777: '23.5R25-Bridgestone-VLT-**',
I'm having like 1,700 lines like this and want every whitespace between the single quotes to dashes. I'm using Notepad++ for this.
My approach:
Find: '(.*?)\s+(.*?)'
Replace: '\1-\2'
But this works for just 2 words.
\s(?!(?:[^']*'[^']*')*[^']*$)
You can use this and replace by -.See demo.
https://regex101.com/r/vP2zF2/2