Search code examples
regexjedit

Regular Expression with intact text



Im using Jedit and regular expression to replace some text in several code from files.

There are a lot of similar start and ends like:

Something
Text Sample
Something Else

Or

Something
I dont know what else
Something Else

Then I search using:

Something
[^‰\r\n]*
Something Else

And I want to replace all lines with:

Something
<Tuv Lang="EN-US">**ORIGINAL TEXT**</Tuv><Tuv Lang="PT-BR"> </Tuv>
Something Else

So it will add some code in the beggining and at the end of the middle text line that is not always equal.

I have tried using:

Something
<Tuv Lang="EN-US">[^‰\r\n]*</Tuv><Tuv Lang="PT-BR"> </Tuv>
Something Else

But without success. Can somebody tell me how is the correct regular expression should I use?

Thanks in advance!

Matias


Solution

  • Try to modify your search to:

    Something
    ([^‰\r\n]*)
    Something Else
    

    This should 'capture' what's inside the brackets and store it in a variable, $1.

    Then, try this replace:

    Something
    <Tuv Lang="EN-US">$1</Tuv><Tuv Lang="PT-BR"> </Tuv>
    Something Else
    

    I can't say if this will work I jEdit or not since I don't have it through.