Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex Search&Replace in Eclipse

Tags:

regex

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 :-(

like image 652
Khazl Avatar asked Nov 18 '25 09:11

Khazl


1 Answers

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.

like image 76
Bart Kiers Avatar answered Nov 20 '25 06:11

Bart Kiers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!