I have a file which has multiple entries like this:
Abcd:abcd:*sometext*:klm:xyz/abc
Abcd:abcd:R%fs90uw:klm:xyz/abc
Now, I want to replace "klm" with "qrs" for only those lines which have the "sometext" string in the line.
How can I do this using the search and replace feature in vim?
Thanks!
:g is your friend:
:g/sometext/s/klm/qrs/g
Related
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.
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.
I've exported a list of users from a website. The list looks like this:
name1
name1#email.com
name2
name2#email.com
name3
name3#email.com
How can I make it look like this using Notepad++? I figure it will need regex & CTRL + H.
name1,name1#email.com
name2,name2#email.com
name3,name3#email.com
Find what: ^([^#\r\n]+)\r\n([^\r\n]+)$
Replace with: $1,$2
You can use this:
find: \r?\n(.*\r?\n?)
replace: ,$1
The idea is to replace the newline with a comma half the time.
I know you have accepted a good answer, but for the record, since Notepad++ uses PCRE, bear in mind that we can use all kinds of features such as \R and subroutines:
Search: (?m)^(?+2)\R++(([\w[:punct:]]+)#(?-1))
Replace: \1,\2
This is clearly over the top, but it's good to know that \R can replace \r\n.
I have words like this in a file.
"abc
"defgh
"ijklmno
"1234
"123
I am able to find the words by using this regexp ^\".*$
I need to append another quote to the text so that the text becomes a quoted text.
How to achieve this?
You can usually just replace
(?<=^").*
by
$0"
If your words always start at the beginning of the line you could record a macro and run it from the beginning to the end of the file.
Otherwise you can use regular expressions:
In notepad++ v6.3.3 this worked for me:
Ctrl + F -> Replace -> Regular expression
Find: ^\".*$
Replace: $0"
The text is newline delimited.
E.g.
Doe, Jon <djon#asasd.com>
Pat, Bob <pbob#askdja.com>
I'd like to extract only the text between < and >, and add a ; (and a newline) between each substring, such that the end result looks like this:
djon#asasd.com;
pbob#askdja.com;
Is this possible with Notepad++? Are there other alternatives with which I could get this done?
Thanks.
Use Search & Replace with enabled Regex checkbox.
Search for:
.*?<(.*?)>
Replace for:
\1;