简体   繁体   中英

Regular Expression Not Working in Notepad++

I am doing a Find & Replace in Notepad++. Each of the pieces work correctly, but when I put the entire string together, it is not working.

I have an old HTML document I am editing where the original page cut up the text, thus:

<div>
    <h2>Title</h2>
    <p>This is a line of[CR][LF]
    text that was cut to[CR][LF]
    fit on screen.</p>
</div>

I want to find the line breaks that are cutting up the text and eliminate them, but not other line breaks.

My regular expression is:

([A-z0-9]+)[\r\n][ ]{3,}([A-z0-9]+)

It will be replaced with:

$1 $2

I have tried each of the pieces of my regular expression and they all find what I would expect: ([A-z0-9]+) finds text, [\\r\\n] is finding my line breaks, [ ]{3,} is finding their initial indents, and ([A-z0-9]+) again finds text.

I have even tried sets of expressions and they all work: ([A-z0-9]+)[\\r\\n] is finding text at the end of a line, [\\r\\n][ ]{3,} is finding line breaks with the indent at the beginning of the new line, and [ ]{3,}([A-z0-9]+) is finding initial indents followed by text.

Perhaps I have two questions: 1) Is this a Notepad++ bug, or have I missed something with my regular expression? 2) Any ideas on solving this by some other expression?

If it is a bug, I suppose I can just trial and error until something works. It would probably be well to report the bug, though, so if anyone can verify that, it would help.

Your regex:

([A-z0-9]+)[\r\n][ ]{3,}([A-z0-9]+)

matches one of \\r OR \\n .

Use this:

([A-Za-z0-9]+)[\r\n]+[ ]{3,}([A-Za-z0-9]+)

or

([A-Za-z0-9]+)\R+[ ]{3,}([A-Za-z0-9]+)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM