how to escape metacharacter like "/" and "." in regex? - regex

Original:
src="this/text/is/not/needed/me/at/all/<filename>.jpg"
src="this/is/another/text/that/is//also/not/required/<filename>.jpg"
My desired output should be:
src="IMAGES/<filename>.jpg"
I want to remove the path of *.jpg file in src="" and want src="images/*.jpg" using regex in notepad++.
How can I do that?

Find what: src=".*/(.*\.jpg)"
Replace with: src="images/$1"

You can try to replace src=".*?\/([^\/]*?\.jpg)" with src="images/$1".

You can use this regex to find -
(src=").*(\/.*\..*")
And replace with -
$1IMAGES$2
A single REPLACE ALL should work.

Replace src=".*/([^/]+.jpg)" with src="images/$1"

Related

In Notepad ++: Replacing some string with something else in all the lines containing another string

In the example below, is there any way to place a string like ("1one1") before {",} at the end of all lines which contain {ī}?
īn:"ZZin",
ín:"FFin",
ǐn:"QQin",
ìn:"TTin",
ie:"XXie",
iē:"TTie",
ié:"GGie",
Thanks
Using Notepad++ regex search for ^(.*ī.*)(",)$ and replace with \11one1\2.
You will need to use regex regex for notepad++.
so, mark "Regular Expression" in the final of Replace box.
in your fields to search:
find what: ī.[^"]"([A-Za-z0-9]*)
replace with: īn:"\11one1
i think it will do what you want. Let me know if it doesn't to edit the regex.

Notepad++ Remove text before characters but have 2 same characters on every line

Hi masters i need your help on Notepad++ RregExpp
i have text like this :
01:example#mail.com:test
need to convert like this :
example#mail.com:test
Thank you in advance if you help me.
Use expression ^... and replace it with empty string or better with \n like following (and remove the first two characters):
Here is a way to go:
Ctrl+H
Find what: ^[^:]+:(.+)
Replace with: $1
Replace all
Make sure to have checked Regular expresion but NOT . matches newline

Switching values

I am struggling with a generic regex to switch values around.
I want a quick way to rearrange
{"AAA","AA1"},
into
{"AA1","AAA"},
ideally using notepad++
Cheers.
Open Replace with Ctrl+H & tick the Regular Expression box
Find: \{(.*),(.*)\}
Replace With: {\2,\1}
(Assumes no } in the quoted values)
in notepad++ :
find :
\{\s*\"(.*?)\"s*\,\s*\"(.*?)\"\s*}
replace by :
{"\2","\1"}
Try this one:
Search: (\{\s*")([^"}]*)(",\s*")([^"}]*)("\})
Replace: \1\4\3\2\5
Pattern: \{("[^"]*")\s*,\s*("[^"]*")\}
Replacement: {$2,$1}
Explanation:
group the "..." parts
use the inverse character class [^"]* to match everything until the first "
reverse their orders with the backreferences: {$2,$1}

Regular Expression Notepad++ to Find & replace strings

I have strings like following in a line
Q80a_Offline_MElDor_NET
Q80a_Offline_Mr_NET
Q80a_Offline_Mor_NET
I want to remove _NET from them using regex in Notepad++.
I also have following in the same line in the file which I don't want to touch.
Q80a_MElDor_NET
Q80a_Mr_NET
Q80a_Mor_NET
I can find these strings with following search string.
^Q80a_offline_[a-zA-Z]+_NET$
but not sure what to use as replace with regex expression
I want Q80a_Offline_MElDor_NET to be Q80a_Offline_MElDor
please help.
_NET$
Try this.Replace by empty string.See demo.
http://regex101.com/r/yR3mM3/55
or
^(Q80a_offline_[a-zA-Z]+)_NET$
Replace by $1.

Notepad++ Regex assistance needed

I have the following example:
assert(apply_patch_check("/system/app/ApplicationsProvider.odex", "31bdc8cc9a131131f97a931933723c0fa6c786ba", "c996ebe1ab91e780dc9b6a41c18214c633413dc4"));
set_progress(0.000153);
assert(apply_patch_check("/system/app/AtciService.odex", "09003fce87c178afb603f4ad7fd9db2e612d0648", "aa28dfd656fd12f38f904f85f85f432a822e7719"));
set_progress(0.000386);
what I need is only:
/system/app/ApplicationsProvider.odex
/system/app/AtciService.odex
How to do that with notepad++
Find what: ^[^"]*"([^"]*).*$
Replace with: \1
Basically use first and second quotation mark to extract text that is in between them.
Try this one too
Find what: (sys.*dex)|.\s? or .*(sys.*dex).*\W
Replace with: $1