Khazl
Khazl

Reputation: 125

Regex Search&Replace in Eclipse

i try to find and replace everything between: <div id="foot"> and <div id="foot_space">

following regular expressions I've already tested:

<div id="foot">(.*?)<div id="foot_space">
#<div id="foot">(.*?)<div id="foot_space">#

The Code looks like:

<div id="foot">
Lorem Ipsum <span>Highlight</span>
</div>
<div id="foot_space"></div>

The remote and file search do not find any matches :-(

Upvotes: 3

Views: 136

Answers (1)

Bart Kiers
Bart Kiers

Reputation: 170138

The . probably does not match \r and \n. Try this:

(?s)<div id="foot">(.*?)<div id="foot_space">

or this:

<div id="foot">([\s\S]*?)<div id="foot_space">

The (?s) enables DOT-ALL, and [\s\S] matches any character. So [\s\S] and (?s). is the same in many regex implementations.

I'd also replace the literal spaces with a \s+ if I were you.

Upvotes: 4

Related Questions