Regex find a line in notepad++ - regex

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"

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.

Find and replace in Notepad++ matching beginning and end of line

I would like to find all lines that follow this format:
type="file_one_id"
type="file_two_id"
type="file_three_id"
And replace them with a single replacement line:
type="my_generic_replacement"
The problem is that there are many other lines which also start with type="file_ or end with _id" , so I'm thinking that searching for lines that both begin with type="file_ and end with _id" will be required. Is there a way to do this with notepad++?
You could search for ^type="file_.*_id"$ (using Regular Expressions) and replace with type="my_generic_replacement"
To replace the lines in Notepad++ you can use this regex:
type="file_\w+_id"
To open the window click Search => Replace
You can find and replace \r\n and tick Extended in the Replace box; \r\n matches carriage-return + line-feed.
Some systems may only have \r or only \n at the line breaks

how to remove new lines in sublime text using regex

I have a text/csv file that looks like this:
I wanted to remove all the blank new lines. How can I do so?
I tried using regex with matching \n, but then this would merge all the lines into one line.
Press ctrl + shift + f
and Replace "\n\n" to "\n"
^[\s]*\n
you can use that, if you elaborate a bit more I could help you to find a more accurate regular expression
with this you should get any line with blank characters,
cheers
For sublime replace[ctrl+alt+f]
use regex \n
replace with <nothing>

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.

Replace string with modified string

I have a file with 1000's of rows looking like
"20140611","20:19","C","IT","IT","HDR","HDPDIT","675605","000000135.97"," ..........
I am trying to replace all occurrences of string that matches this pattern :
quote then 6 numerics followed by a closing quote ( i.e. "675605" with "675605#")
Using edit plus regular expression search and replace, the search string is :
\"[0-9][0-9][0-9][0-9][0-9][0-9]\"
This will find all the occurrences I need
However I'm unable construct the correct replace with reg ex to replace the match with itself followed by the # sign e.g. "675605#
With sed you can have:
sed -r 's|"([0-9]{6})"|"\1#"|g' file
Add -i to modify it inline.
So my proposed regex - replacement form is:
"([0-9]{6})" - "\1#"
Quoted:
\"([0-9]{6})\" - \"\\1#\"
Regex:
\"([0-9][0-9][0-9][0-9][0-9][0-9])\"
Replacement string:
"\1#
DEMO
Replacement string would be "\1" if you want "675605#"
You need to use capturing groups. I don't know if you can use them in Edit Plus, but I think it should work:
Find what: \"(\d{6})\"
Replace with: \"\1#\"
Where \1 is a number captured in parenthesis.
Open your file in vim or vi editor using below command:
vi "filename"
then use this command it replace your "675605" pattern with "675605#"
:%s/675605/675605#/g
then
esc :wq
now you open your file it replaced all your "675605" pattern with "675605#".