Oooupps ! You’re quite right about it ! I didn’t notice the space character, right after<p class="best"> and right before</p>, once the S/R is done :-((

Here is one possible solution ( the shorter one that I could find out, yet ! ) :

SEARCH (?-si)((<p class="best">)|\G)((?!</p>).)*?\K\h+(?=(</p>)|)

REPLACE ?2:(?4:\x20)

Notes : In replacement, the conditional syntaxes lead to the following logic :

If group 2 exists ( the starting tag = <p class="best"> ), we do nothing, so the blank chars matched \h+ are deleted

Else, if group 4 exists ( the ending tag = </p> ), in the same way, the blank chars matched \h+ are deleted

Else ( case where blank character(s) matched ( \h+ ) are, both, not preceded with <p class="best"> and not followed with </p> ), a single space char replaces the overall range of blank characters \h+, whatever they are !

So, for instance, the text :

abc def <p class="best"> I go home with my mother </em> and my father is watching tv. </p> abc def

Within the positive look-behind, at the end of the regex, we may not use the alternation symbol | ) and use, instead, the (?=(</p>)?) syntax, with the optional group </p> ! The replacement regex is identical

but, seems that I didn’t mention this one. In my html pages, I have both kind of lines. Some lines with tags that contains 2-3 SPACES between words, and tags that have only one space (those are good).

So, I need to Replace just those lines that have more then one space between words (like your regex, very good). But leave alone those who don’t have two or more spaces between words (such as the second line).

This is the third time you’ve changed the requirements after the original request. If what Guy has given you is close, then using the examples and details that Guy has given you, plus the documentation linked in the Community FAQ or directly in the official Notepad++ Documentation set, you should be able to give it a try, and attempt to make your requested fixes yourself.

After you’ve tried, if it works, great! If not, show us what you tried, why you thought it would work, and give examples of how it didn’t work right. We’re here to help you learn how to use the tool, not to just supply all your regexes without any effort from you.

-----

Please Read And Understand This

FYI: I often add this to my response in regex threads, unless I am sure the original poster has seen it before. Here is some helpful information for finding out more about regular expressions, and for formatting posts in this forum (especially quoting data) so that we can fully understand what you’re trying to ask:

This forum is formatted using Markdown. Fortunately, it has a formatting toolbar above the edit window, and a preview window to the right; make use of those. The </> button formats text as “code”, so that the text you format with that button will come through literally; use that formatting for example text that you want to make sure comes through literally, no matter what characters you use in the text (otherwise, the forum might interpret your example text as Markdown, with unexpected-for-you results, giving us a bad indication of what your data really is). Images can be pasted directly into your post, or you can hit the image button. (For more about how to manually use Markdown in this forum, please see @Scott-Sumner’s post in the “how to markdown code on this forum” topic, and my updates near the end.) Please use the preview window on the right to confirm that your text looks right before hitting SUBMIT. If you want to clearly communicate your text data to us, you need to properly format it.

If you have further search-and-replace (“matching”, “marking”, “bookmarking”, regular expression, “regex”) needs, study the official Notepad++ searching using regular-expressions docs, as well as this forum’s FAQ and the documentation it points to. Before asking a new regex question, understand that for future requests, many of us will expect you to show what data you have (exactly), what data you want (exactly), what regex you already tried (to show that you’re showing effort), why you thought that regex would work (to prove it wasn’t just something randomly typed), and what data you’re getting with an explanation of why that result is wrong. When you show that effort, you’ll see us bend over backward to get things working for you. If you need help formatting, see the paragraph above.

Please note that for all regex and related queries, it is best if you are explicit about what needs to match, and what shouldn’t match, and have multiple examples of both in your example dataset. Often, what shouldn’t match helps define the regular expression as much or more than what should match.

Help us help you. Show effort. Give us a reason to want to continue to help you. Right now, it feels like you’re asking us to do your homework (or worse, the job you’re being paid to do) for you, for free.

I am not a scientist, not a programmer, just know how to use regex.

You don’t have to be a scientist nor a programmer to be able to follow advice and read documentation and try to understand what’s already been explained and given to you, and try to modify that to fit your actual needs.

No one is bound to help me.

Definitely true. But using phrases like “Must change” makes it sound rather demanding. (I understand that English might not be your native language.)

But part of my definition of “help” is “help the person learn”, not “just give them the answer”. If we help you to learn how to do this yourself, you could be much more efficient in writing your HTML website (waiting hours or days for one of us to write a regex for you is rather inefficient). By encouraging you to learn regex yourself, rather than just relying on us to write the regex for you, we are trying to help you.

Not always. There have been long stretches when he’s not around. And who knows, he might go the same way as others of the long-time contributors to the forum. Or the forum may be killed off when Don gets tired of it. In the long term, it’s better for you to learn.

One of the best ways to learn regex is to study what’s been given, try to make changes that you think will work the way you want it to, and then ask specific questions if it doesn’t work as you expected.

And one of the best ways to get the regex you want on the first time you ask the question, rather than having to do 3+ iterations, is to give truly-representative data sets. Make sure the example data you post includes both lines that you want to be changed and ones you don’t; make sure they include a reasonable variety of spacing variations, to make it clear when you want space to be important and when you don’t.

This is all advice to help you learn, and to help you ask better questions in the future.

As always, regexes should always be processed against real user text ! Vasile, this issue has nothing related to leading tab characters ! It’s, simply, because, in your 3rd and 4th line, the starting tag is not followed with any space char !

RIGHT (?-si)(?<=<p class="best">)\K\h*|\G((?!</p>).)*?\K(\h+(?=</p>)|\h\K\h+)

Indeed, because of the \G syntax and the fact that the dot. did not process EOL chars, when the regex engine processes possible blank characters before </p>, the only possibility that the S/R process goes on and skips to next line is to match, first, the first alternative of the regex, i.e. the new beginning part (?<=<p class="best">)\K\h*, which allows possible lack of blank chars ;-))

Then, due to the \G feature, further blank characters on this next line can be deleted !