NoviceMe
NoviceMe

Reputation: 3256

Searching for similar string in eclipse using regex

I have following file:

<rules>
    <q>abc</q>
    <a>1</a>
    <q>bcd</q>
    <a>2</a>
    <q>abc</q>
    <a>3</a>
</rules>
<rules>
    <q>bcd</q>
    <a>2</a>
    <q>edc</q>
    <a>4</a>
    <q>abc</q>
    <a>3</a>
</rules>

I want to basically file xml node with same text on search. So in this case i want to find abc when i search. Can someone please suggest regular expression for this? Or any other way to do this?

Upvotes: 0

Views: 81

Answers (2)

NoviceMe
NoviceMe

Reputation: 3256

Enhancing FailedDev's answer a bit to get my wanted result. May be this will help somebody else looking for same thing:

//q[not(text() = '') and text() = following-sibling::q/text()]

Upvotes: 1

Qtax
Qtax

Reputation: 33928

I don't know what features Eclipse regex supports, but this could work if supported:

<q>([^<]+)</q>.*<q>\1</q>

With some "dot matches new lines" flag (like (?s)).

Upvotes: 0

Related Questions