Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

regex - Need to remove dashes inside an XML node with a regular expression

In an XML file I need to remove the dashes in the < ssn > node, ###-##-#### . I can't remove all dashes from the file since other nodes, like < phone > and <federal_id> need their dashes.

I don't need to use a regular expression if there is another method that is easier.

Here is an example of the file:

<Billing>
    <corrected></corrected>
    <ssn> 123-12-1234 </ssn>
    <addr_line3> 909-555-1234                     </addr_line3>
    <trayear> 2020 </trayear>
    <federal_id> 95-12345123      </federal_id>
    <service_provider></service_provider>
    <reporting_method> X </reporting_method>
</Billing>

I can remove all dashes with a sed command: sed "s/- //g"

but I need them in some nodes still < federal_id > and < addr3_line >

question from:https://stackoverflow.com/questions/65945232/need-to-remove-dashes-inside-an-xml-node-with-a-regular-expression

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...