How to replace the single quotes on Word/notepad++ - regex

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

Related

Notepad++ replacing a word with a number in parens

Using Notepad++, how do I replace a word with a number within ()?
For instance, replace the word "serial" with "(1234)"? When I try to do this, the word "serial" is replaced with "1234", but without the parens.
In Notepad++ the parenthesis have to be escaped in the replacement part.
Ctrl+H
Find what: serial
Replace with: \(1234\)
CHECK Wrap around
CHECK Regular expression
Replace all
Screen capture (before):
Screen capture (after):
Choosing Extended (\n,\r,\t,\0, \x...) as the Search Mode and just specifying (1234) as the Replace with value worked fine.
The answer by Toto solves my problem.
In Notepad++ the parenthesis have to be escaped in the replacement part.
Ctrl+H
Find what: serial
Replace with: (1234)
CHECK Wrap around
CHECK Regular expression
Replace all

Trying to replace some text in Notepad++

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.

Regular expression Notepad++

Good Morning in my timezone
I want to replace a character that is in the beginning of each line
So i had used the following regular expression to find the text
^\d
And it works fine in finding all the characters
The problem is in the replace with
I want to replace with single quote followed by the same character found above
How can i do it ?
Thanks in advance
You may try this option:
Find:
^(?=\d)
Replace:
' <-- just a single quote
The find pattern uses a positive lookahead which asserts that the first character is a digit, but nothing is ever matched. Then, the replacement is a single quote.
You may use
Find What: ^\d
Replace With: '$0
where $0 is the backreference to the match value.
Another one would be:
Find:
^(\d)
Replace:
'\1
In this example \1 would be 1st captured group.

How in notepad++ find/replace text between slashes?

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

How to cut string with Regex and Notepad++

I need to use Notepad++ to cut the string in the text file using regex.
I have this type of strings: "<a href="/groups/1122some_text_here/sometexthere"AnotherText
I need to replace it with: "<a href="/groups/1122/"AnotherText
I need to keep only numbers and close it with slash.
I could get all entries with /groups/[\d].* regex.
How to replace it in a right way?
You can use the following replacement:
Find What: (?<=/groups/)(\d+).*?"
Replacement: $1/>
Or, perhaps, adding the closing angle bracket:
Find: (?<=/groups/)(\d+).*?"
Replace: $1/">