REGEX again: How can I select/mark this 3 works on a different lines
-
hello guy38, I wasn’t here, sorry.
So, I test all your new regex. First, the long regex, replace by#$0
works very good.The little problem are the next 3 SUCCESSIVELY regex. One by one. After Search and Replace with
\1
, I get the successful message “6 occurrences has were replaced.”The problem is that, in fact, nothing has changed…is like nothing happen…
The last of the 3 successively regex
(?-s)^#.*(Recente|Coments|Tags).*
, after replace with\1
, removes the # sign witch I had put with the first long regex -
Oh, WORKS ! I use another example. So, excuse-me. All your regex works just fine guy38. You practically move all 3 words to the beginning of lines.
Thanks a lot
-
and, I return to my old problem. Now with your help, I manage to take all 3 words to the start of the lines. The question was, how can I mark/delete something before or after those 3 words. For example:
text bla Commens
text bla bla TagsRecente
Coments
Tagstext bla Recente
text bla bla TagsSo, you see that the words “Recente, Coments and Tags” are repeating. So, I manage to resolve my first problem: HOW TO DELETE EVERYTHING BEFORE THOSE 3 words on the 3 successively lines, included those 3 lines:
Search
((?s)((^.*)^Recente|^Coments|^Tags))(.*$)
Replace by:
Leave empty
-
Now, to delete everything after those 3 words (and 3 lines) included those 3 lines
Search:
^.*(?s)^Recente|^Coments|^Tags.*[\s\S]
Replace by:
leave empty
-
so, you see my friend, where I wanted to get. The single problem was that all that 3 words, were somewhere in the middle of the lines, and I didn’t know how to select those SUCCESSIVELY lines.
thanks a lot.
But If you know another 2 regex to do directly this, for deleting before and after, without adding the 3 words at the beggining at the lines, please let me know.
-
Vasile,
I’m just back on our forum and, after reading your post, where you said :
The problem is that, in fact, nothing has changed…is like nothing happen…
I quickly guessed why it did NOT work :-) Ah ! Again, I forgot to add this VERY IMPORTANT fact :
If your pattern regex contains one or more look-behinds AND/OR any
\K
form, you must, EXCLUSIVELY use the Replace All button to perform a global replacement.DON’T use the Replace button, for a step by step replacement : it does NOTHING !!
So, for performing, correctly, my three previous regexes :
(?-s)^#(?:.+\R){2}\K.*(Recente|Coments|Tags).*
(?-s)^#.+\R\K.*(Recente|Coments|Tags).*
(?-s)^#.*(Recente|Coments|Tags).*
with replacement
\1
-
Move the caret, before the text to change
-
Perform the three S/R, in that order, by clicking, EXCLUSIVELY, on the Replace All button ( Not the Replace button !! )
It should be OK
Of course, don’t forget to delete the extra
#
character, at the endCheers,
guy038
So, I updated my previous post !
-
-
WORKS !!!
-
A different nice regex looks like this. First check . match newline
Search:
.*\n([ \t]+Recente\s+Coments\s+Tags).*
REPLACE By:
$1
or\1
Don’t forget to check . match newline
This will select all that 3 words, even if are delimitaded by tab or spaces. And will delete the rest of document.
But how can I use this regex, to remove everything only before those 3 words, and another regex to remove only after those 3 words? -
or, without check . match newline
Search:
(?s).*\n([ \t]+Recente\s+Coments\s+Tags).*(.*$)
REPLACE By:
$1
or\1
-
hello, I find the solutions:
So, to delete everything before those 3 words, included the 3 lines with the words:
Search:
(?s).*\n([ \t]+Recente\s+Coments\s+Tags)
Replace By:
Leave Empty
Delete everything after those 3 words included the 3 lines with the words:
Search:
(?s)([ \t]+Recente\s+Coments\s+Tags)(.*$)
Replace by:
$1