RegEx problems
-
I don’t know that you needed to bother in this one; he seems to think he has a working expression, from what I can tell.
-
This post is deleted! -
@PeterJones
Replace With:(?1\1\x20)(?2\3)You wrote it
(?1
and(?2?. In general, I asked for an example where without this
(?1` formula will not work.I counted most on @guy038.
Instead, he sends me elsewhere for a reply.It cannot write that this
(?1
or(?2
is redundant.So far I think
(?1
or(?2
is redundant at all.I’m not questioning anyone’s knowledge, but I want to understand it through examples.
And since I have my opinion, I’m definitely a Russian troll.
-
@Pan-Jan said in RegEx problems:
I have a request to show me a specific example,
when is it necessary to use this (?1)If you want an example of where the ?1, ?2 are needed how about searching through old posts here. In particular I found this one which is just perfect for you to get a better understanding.
https://community.notepad-plus-plus.org/topic/16533/how-to-remove-empty-spaces-from-a-particular-tag-regular-expression
Often there are several versions of regexes which will solve the original posters problem. As long as they do fit the examples provided they can be regarded as correct.Your recent images suggesting your revised version will add a space where none is, I do NOT believe it. If you want to prove that it does you need to make ALL characters show including line endings (carriage returns, line feeds etc). To do this use the view menu option to show other characters and “show all characters”. Then post the image again proving that ABC has no space behind and the regex adds one.
Good luck
Terry -
@Terry-R said in RegEx problems:
will add a space where none is, I do NOT believe it.
I don’t believe anymore either.
You were right
ABC was with a space
1
2the space was invisible
formula used there:
Find What:(\w+$)|(\R(\d+))
Replace With:(?1\1\x20)(?2\3)my corrected pattern:
Find What:(\w+)|\R(\d+)
Replace With:(?1\1 )\2
https://community.notepad-plus-plus.org/topic/16533/how-to-remove-empty-spaces-from-a-particular-tag-regular-expression
this is an example from this link:<p class=“oyric”> Laurie to her final confrontation with Myers, the masked figure who has her since she escaped. </p>
Output should be:
<p class=“oyric”>Laurie to her final confrontation with Myers, the masked figure who has her since she escaped.</p>formula used there:
Find What:(?s)(?:\G|<p class=“oyric”>)(?:(?!<|>).)*?\K(?:(^\h+)|\h+$|(?<=>)\h+|\h+(?=</p>)|(\h{2,})(?=[^<\h]))
(?1$0)(?2\x20)my corrected pattern:
Find What:(?<=>)\h+|\h+(?=<)|(\h+)
Replace With:?1\x20
I can not do without it
?1
It looks like it’s needed. -
This is correct:
Find What:>\K\h+|\h+(?=<)|
(\h+)
Replace With:?1\x20
I moved the
(\h+)
insideFind What:
>\K\h+|
(\h+)|\h+(?=<)
Replace With: ???Is there no solution here?
-
@Pan-Jan said in RegEx problems:
Is there no solution here?
It’s only because I’m intrigued with your questions (with very little to back them up) that I will reply.
You have been requested many times that when posting questions to also supply data (using the black boxes) so that others may see what you have and what you want to get. However in this case I see it seems to refer to the original link I sent in the previous post and to which you have responded with your version of an answer. Now you have altered your own regex and found it doesn’t appear to work I suppose and have presented a new problem to us.
I will point you back to the manual for NPP, specifically the “Control Flow” area in which it references the alternation symbol
|
.
https://npp-user-manual.org/docs/searching/#control-flow
Note the sentence
Matches are attempted from left to right.
Possibly this is the issue. Anyways I’m not interested in actually solving your question as the original question was solved sometime ago.But by all means, consider going through old posts and seeing if you can find your own solutions, same or different from the original. That would work well as a self teaching process. There is no need to post your answers on any old posts for us, it will be sufficient that in your mind you have accomplished solving it.
Terry
-
God, it can’t be,
better not to change.