Home > Software engineering >  Replace XML initial tag with regex in JS
Replace XML initial tag with regex in JS

Time:08-11

I want to get all the strings starting with <?XML and ending with ?> to replace in Javascript strings.

For example <?XML version="1.0" encoding="UTF-8" ?> should be replaced with ''

because parsing it is resulting in an error.

CodePudding user response:

regex that starts with <?XML and ends with ?> should be given as

<\?\s*XML.*\?>

  • Related