Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Here's my problem: In a .txt file, I need to find and replace thousands of instances of syntax like this:

(see (a053007djfgspwdf))

or

(see (a053007djfgspwdf) and (a54134xsedgeg))

or

(see (a053007djfgspwdf), (a9554xsdfgsdfg) and (a54134xsedgeg))

There is a lot of variety between the beginning (see (a and the ending )) text strings. Can this be set up in Notepad++ using regex? If so, how would I do that? Thanks!

share|improve this question

3 Answers 3

Yes it can! Notepad++ has a RegEx search mode that you can select for all of your RegEx replacement needs.

The example below is a basic replace for anything between (see (a...)) with the exception of a line break. You may need to modify the RegEx or write your own to fit your needs. Here's a great place to help you along with experimenting.

RegEx: \(see \(a.+\)\)

Matched strings:

(see (a053007djfgspwdf))
(see (a053007djfgspwdf) and (a54134xsedgeg))
(see (a053007djfgspwdf), (a9554xsdfgsdfg) and (a54134xsedgeg))


Replace (see (a...)) with replacement

share|improve this answer
    
Thanks! It found the instances of the first example (see (a053007djfgspwdf)) but not the others. Still, a great start. I will play with it to see what else I can do. If you have further suggestions, I would very much appreciate it. Thanks again. –  Michael Tuck Aug 27 '13 at 23:49
    
Did you click Replace All or continue clicking on Replace to cycle through matches similar to using Find Next? Does the text you're looking for only start with (see (a and end with ))? If you have strings that end with a single parentheses, you can turn the last \) into the capture group (\)|) to match strings ending with )) "or" ). –  one.time Aug 28 '13 at 0:08
    
Tried a few replaces, then Replace All. After that, the search string found nothing. The text for all is: (see a varied text )) No strings with single parenthesis except perhaps typos. –  Michael Tuck Aug 28 '13 at 1:20
    
I updated my answer with an alternative RegEx (\(see \(a|\(a)([^\)]+)\)(\)|) that will match on the strings in your question. –  one.time Aug 28 '13 at 1:22
    
LOL you updated your answer while I was editing my response. I'll try the new one. –  Michael Tuck Aug 28 '13 at 1:23

Try this pattern: \(see \(a(.*)\) and make sure you have ". matches newline" unchecked and "wrap around" checked.

share|improve this answer
    
Will give it a shot, Thomaz. Thanks. –  Michael Tuck Aug 28 '13 at 20:39

The exact regex you'd need is:

\(see \(\w+\)((, \(\w+\))*( and \(\w+\)))?\)

For example:

enter image description here

On selecting Find All in Current Document, the result would be:

enter image description here

You can simply use Replace as per your necessity instead.

If you want to include the a as well in the regex, you can use:

\(see \(a\w+\)((, \(a\w+\))*( and \(a\w+\)))?\)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.