I have a large file with content inside every bracket. This is not at the beginning of the line.
1. Atmos-phere (7800)
2. Atmospheric composition (90100)
3.Air quality (10110)
4. Atmospheric chemistry and composition (889s120)
5.Atmospheric particulates (10678130)
I need to do the following
Replace the entire content, get rid of line numbers1.Atmosphere (10000)
to plain Atmosphere
Delete the line numbers as well
1.Atmosphere (10000)
to plain Atmosphere
make it a hyperlink
1.Atmosphere (10000)
to plain <a href="http://blahqd.com/Atmosphere.htm">linky study</a>
[I added/Edit] Extract the words into a new file, where we get a simple list of key words. Can you also please explain the numbers in replace the \1\2, and escape on some characters
Each set of key words is a new lineAtmospheric
Atmospheric composition
Air quality
Each set is a on one line separated by one space and commasAtmospheric, Atmospheric composition, Air quality
I tried find with regex like so, \(*\)
it finds the brackets, but dont know how to replace this, and where to put the replace, and what variable holds the replacement value.
Using Regex to find and replace text in Notepad++ In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string). And also ensure the 'Regular expression' radio button is set.
Find tab: Gives access to searching and counting. It can be invoked directly with Search > Find or the keyboard shortcut Ctrl+F . Replace tab: Similar to Find tab, but allows you to replace the matched text after it's found. It can be invoked directly with Search > Replace or the keyboard shortcut Ctrl+H .
Here is mine exression for notepad ([0-9(). ]*)(.*)(\s\()(.*)
You need split your search in groups
([0-9. ]*)
numbers, spaces and dots combination in 0 or more times
(.*)
everything till next expression
(\s\()
space and opening parenthesis
(.*)
everything else
In replace box - for practicing if you place
\1\2\3\4
this do nothing :) just print all groups from above from 1.1 to 1.4
\2
this way you get only 1.2 group
new_thing\2new_thing
adds your text before and after group
<a href=blah.com/\2.html>linky study</a>
so now your text is added - spaces between words can be problematic when creating link - so another expression need to be made to replace all spaces in link to i.e. _
\\
for backslash or \$
for dolar signWant more tune - <a href=blah.com/\2.html>\2</a>
add again 1.2 group - or use whichever you want
On the screenshot you can see how I use it (I had found and replaced one line)
Ok and then we have case 4.2 with colon at the end so simply add colon after extracted section:
change replace from \2
to \2,
Now you need join it so simplest way is to Edit->Line Operations->Join Lines
but if you want to be real pro switch to Extended mode
(just above Regular expression
mode in Replace
window) and Find \r\n
and replace with space.
Removing line endings can differ in some cases but this is another story - for now I assume that you using windows since Notepad++ is windows tool and line endings are in windows style :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With