Locate and insert new value
-
Hi all,
I need a big help to locate and insert value operation in np++
Below you can see the required part from XML file. I need to locate <t_to> then <to_person> and insert <nationality1>US</nationality1> tag below the <ssn>
tag.
<t_to>
<to_funds_code>CASH</to_funds_code>
<to_person>
<first_name>ANTHONAN BETHO PERERA</first_name>
<last_name>GOTHEN</last_name>
<ssn>6115456465465A</ssn>
nationality1>US</nationality1>
</to_person>
<to_country>FR</to_country>
</t_to> -
Using the technique shown HERE, this seems to do it:
find:
(?s-i:<t_to>.*?<to_person>|(?!\A)\G)(?s:(?!</to_person>.*?</t_to>).)*?\K(?-i:</last_name>\R)
repl:$0<ssn>6115456465465A</ssn>\r\n
mode: Regular expression -
Hello, @gonka-weerakoon, @alan-kilborn and All,
@alan-kilborn, I"m surprised and don’t understand your regex replacement ! Perhaps, I’m missing something obvious !
@gonka-weerakoon, if all your sections, below, contains
<ssn>xxxxxxxxxxxx</ssn>
matchings tags :<t_to> ... <to_person> ... ... <ssn>6115456465465A</ssn> </to_person> ... </t_to>
Then :
-
Open the Replace dialog (
Ctrl + H
) -
SEARCH
(?s-i)<t_to>.*?<to_person>.*?</ssn>\R\K
-
REPLACE
nationality1>US</nationality1>\r\n
-
Untick all options
-
Tick the
Wrap around
option -
Select the
Regular expression
search mode -
Click once on the
Replace All
button ( do not use the Replace button ! )
In case that some sections
<t_to>............</t_to>
do not contain a<ssn>xxxxxxxxxxxx</ssn>
part, just tell me in order to modify the search regex accordingly !Best Regards,
guy038
-
-
@guy038 said in Locate and insert new value:
I"m surprised and don’t understand your regex replacement
I don’t understand it now either.
For some reason I thought OP wanted to insert the ssn tag and value!
Oops.