I\'m using Notepad++ and I can\'t figure this out :
I have numerous lines all starting with http
. I need to add some text in front of it in every line.
You can automatically do it in Notepad++ (add text at the beginning and/or end of each line) by using one regular expression in Replace (Ctrl+H):
Explanation: Expression $1
in Replace with input denotes all the characters that include the round brackets (.*)
in Find what regular expressin.
Tested, it works.
Hope that helps.
Simply in the "Find what:" field, type \r
. This means "Ends of the Row". In the "Replace with:" field, you put what you want for instance .xml
if you have several lines, and you are aiming to add that text to the end of the each line, you need to markup the option ". matches newline" in the "Search Mode" group box.
Example:
You have a file name list, but you want to add an extension like .xml. This would be what you need to do and Bang! One shot!:
See the image here
If you have thousands of lines, I guess the easiest way is like this:
-select the line that is the start point for your cursor
-while you are holding alt + shift select the line that is endpoint for your cursor
That's it. Now you have a giant cursor. You can write anything to all of these lines.
Follow these steps:
Regular expression
option near the bottom of the dialog.To add a word, such as test
, at the beginning of each line:
- Type
^
in theFind what
textbox- Type
test
in theReplace with
textbox- Place cursor in the first line of the file to ensure all lines are affected
- Click
Replace All
button
To add a word, such as test
, at the end of each line:
- Type
$
in theFind what
textbox- Type
test
in theReplace with
textbox- Place cursor in the first line of the file to ensure all lines are affected
- Click
Replace All
button
Open Notepad++, then click Ctrl+ F.
Choose Regular Expression
*Find What: "^" (which represents index of the each line - "PREFIX").
Replace with : "anyText"*
For Suffix on each line: Follow the same steps as above "Replace ^ with $" . That's it.
In order to do it in one go:
http:\blahblah.com
http:\blahnotblah.com
http:\blahandgainblah.com
^(.+)$
. Here ^ represents the start of the line. $ represents the end of the line. (.+) means any character in between the start and the end of the line and it would be group 1.WhateverFrontText(\1)WhatEverEndText
. Here (\1) means whatever text in a line.WhateverFrontTexthttp:\blahblah.comWhatEverEndText
WhateverFrontTexthttp:\blahnotblah.comWhatEverEndText
WhateverFrontTexthttp:\blahandgainblah.comWhatEverEndText