Help - Multiple replacement - Vertical text
-
Hi guys, I have a problem , I am trying to do a multiple replacement in a text like this:
<MANUFACTURER_PID>Luis</MANUFACTURER_PID>
<MANUFACTURER_PID>Rosa</MANUFACTURER_PID>
<MANUFACTURER_PID>Ernesto</MANUFACTURER_PID>
<MANUFACTURER_PID>Matias</MANUFACTURER_PID>
I want to replace those names for numeric codes so I am doing a multiple replacement with the “multiline find and replace” plug in and also regular expresions, looks like this:
Find Box:
(<MANUFACTURER_PID>Luis</MANUFACTURER_PID>)|
(<MANUFACTURER_PID>Rosa</MANUFACTURER_PID>)|
(<MANUFACTURER_PID>Ernesto</MANUFACTURER_PID>)|
(<MANUFACTURER_PID>Matias</MANUFACTURER_PID>)|Replace Box:
(?1<MANUFACTURER_PID>07498358092</MANUFACTURER_PID>)
(?2<MANUFACTURER_PID>07498311593</MANUFACTURER_PID>)
(?3<MANUFACTURER_PID>07498319913</MANUFACTURER_PID>)
(?4<MANUFACTURER_PID>07498351833</MANUFACTURER_PID>)the problem is that I get empty spaces added after each line replaced, is there any way to avoid that???
help please!!.
Note: I need the pipe symbol | because the original lines may not be right after each other (there maybe text in between each line)
Also it is important to mention that my text is sorted in vertical just like I put it here. -
Your replacement works for me pretty much as you stated it. This may be a key point as to why it isn’t working:
important to mention that my text is sorted in vertical just like I put it here
…but I don’t understand what it means.
I used your data with these exact fields for regex replacement:
Find what:
(<MANUFACTURER_PID>Luis</MANUFACTURER_PID>)|(<MANUFACTURER_PID>Rosa</MANUFACTURER_PID>)|(<MANUFACTURER_PID>Ernesto</MANUFACTURER_PID>)|(<MANUFACTURER_PID>Matias</MANUFACTURER_PID>)
Replace with:
(?1<MANUFACTURER_PID>07498358092</MANUFACTURER_PID>)(?2<MANUFACTURER_PID>07498311593</MANUFACTURER_PID>)(?3<MANUFACTURER_PID>07498319913</MANUFACTURER_PID>)(?4<MANUFACTURER_PID>07498351833</MANUFACTURER_PID>)
-
Hi Scott Sumner, thanks a lot for taking time to see my post, what I mean is that my text is in vertical position like this:
<MANUFACTURER_PID>Luis</MANUFACTURER_PID>
<MANUFACTURER_PID>Rosa</MANUFACTURER_PID>
not like this:(<MANUFACTURER_PID>Luis</MANUFACTURER_PID>)|(<MANUFACTURER_PID>Rosa</MANUFACTURER_PID>) etc.
the replacement works but when I do it I get empty lines in between like this:
<MANUFACTURER_PID>012345678910</MANUFACTURER_PID>
<MANUFACTURER_PID>012345678911</MANUFACTURER_PID>
I cannnot sort my text in a horizontal way like you mentioned because is part of a very large XML file
-
I did NOT suggest sorting lines…maybe we have a language barrier.
If I start with these lines:
<MANUFACTURER_PID>Ernesto</MANUFACTURER_PID> <MANUFACTURER_PID>Luis</MANUFACTURER_PID> <MANUFACTURER_PID>Matias</MANUFACTURER_PID> <MANUFACTURER_PID>Rosa</MANUFACTURER_PID> <MANUFACTURER_PID>Matias</MANUFACTURER_PID> <MANUFACTURER_PID>Rosa</MANUFACTURER_PID> <MANUFACTURER_PID>Matias</MANUFACTURER_PID> <MANUFACTURER_PID>Luis</MANUFACTURER_PID> <MANUFACTURER_PID>Luis</MANUFACTURER_PID> <MANUFACTURER_PID>Rosa</MANUFACTURER_PID> <MANUFACTURER_PID>Ernesto</MANUFACTURER_PID> <MANUFACTURER_PID>Matias</MANUFACTURER_PID> <MANUFACTURER_PID>Rosa</MANUFACTURER_PID> <MANUFACTURER_PID>Luis</MANUFACTURER_PID> <MANUFACTURER_PID>Rosa</MANUFACTURER_PID> <MANUFACTURER_PID>Matias</MANUFACTURER_PID> <MANUFACTURER_PID>Luis</MANUFACTURER_PID> <MANUFACTURER_PID>Ernesto</MANUFACTURER_PID> <MANUFACTURER_PID>Ernesto</MANUFACTURER_PID> <MANUFACTURER_PID>Rosa</MANUFACTURER_PID> <MANUFACTURER_PID>Ernesto</MANUFACTURER_PID> <MANUFACTURER_PID>Ernesto</MANUFACTURER_PID> <MANUFACTURER_PID>Luis</MANUFACTURER_PID> <MANUFACTURER_PID>Matias</MANUFACTURER_PID>
and do the replacement I suggested above (which isn’t really different from your original one), I get this (which looks correct and has no empty lines):
So without more information I can’t say what is going wrong for you. :-(
-
Hi Scott, thanks again for taking time for my post. I think that I know why we get differet results.
I am sorting my data in the find and replace boxes also in a vertical way, I have tried what you said and you are correct there are not empty lines added but when I do it my way I get the extra empty lines.now let me explain why I go this way. I am working with a very large XML file, it has mmillions of lines. the lines that I want to replace are among many many lines that I don’t want to touch.
to be clear there are 51200 lines that I want to replace, those are like the ones in my examples. I need to replace them with other 51200 lines that instead of having names like Rosa, Luis, etc. they have numeric codes just like the examples.I would go as you say placing the text in the find box like this:
(<MANUFACTURER_PID>Luis</MANUFACTURER_PID>)|(<MANUFACTURER_PID>Rosa</MANUFACTURER_PID>)| ETC…
in a horizontal way and doing the same in the same in the replace box like this:
(?1<MANUFACTURER_PID>07498358092</MANUFACTURER_PID>)(?2<MANUFACTURER_PID>07498311593</MANUFACTURER_PID>)…but as I mentioned I have to put in there in the find and also in the replace boxe 51200 pieces of text so I have no way to do that.
in this forum I am not able to attach anything but I will try to generate links fot the files I am working with so maybe you can take a look.thanks a lot
-
If I’m interpreting you correctly then see if this thread helps you: https://notepad-plus-plus.org/community/topic/14548/help-replacing
If it doesn’t, post again here…
-
Hello, @luis-eduardo-martinez-ruiz, and All,
Indeed, Scott gave you the right link to the related discussion to your problem ! But, as this discussion contains many posts and as you could be a bit “lost”, I think that I’m able to build a suitable regex for your needs :-))
You said, in your first post :
I want to replace those names for numeric codes
And you gave an example, with 4 forenames ( I just copied real text ! ) :
<MANUFACTURER_PID>Luis</MANUFACTURER_PID> .... <MANUFACTURER_PID>Rosa</MANUFACTURER_PID> ... <MANUFACTURER_PID>Ernesto</MANUFACTURER_PID> ... <MANUFACTURER_PID>Matias</MANUFACTURER_PID>
which have to be replaced by the 4 numeric codes ( Again, I just copied real text, not the regex ! ) :
<MANUFACTURER_PID>07498358092</MANUFACTURER_PID> ... <MANUFACTURER_PID>07498311593</MANUFACTURER_PID> ... <MANUFACTURER_PID>07498319913</MANUFACTURER_PID> ... <MANUFACTURER_PID>07498351833</MANUFACTURER_PID>
So I suppose that you have a specific file which links up these forenames to the numeric codes, and vice-versa. I mean, a file like that :
Luis : 07498358092 Rosa : 07498311593 Ernesto : 07498319913 Matias : 07498351833
or, may be, like that :
07498358092 = Luis 07498311593 = Rosa 07498319913 = Ernesto 07498351833 = Matias
Just tell me the structure of this specific file ( that I call the links file ), and we’ll be able to get the right regex S/R, which allows the change of any number of names, possibly repeated, with their respective numeric codes ( even 52000 items ! ) in one step, only :-))
Remarks :
-
ONE condition is mandatory : In this links file, all the names and numeric codes must be UNIQUE !
-
The order of names, in the initial text, can be completely different than the order they occur, in the links file. No problem !
-
And, as I said above, some names may be repeated, in the text to be changed. No problem, too !
See you later,
Best Regards,
guy038
-