use XSLT to remove/replace invalid characters

前端 未结 2 716
-上瘾入骨i
-上瘾入骨i 2021-01-25 22:56

I am looking for as way to test a given element in the source XML and remove characters that are not valid. Basically I have a list of allowed characters and need a way to repl

2条回答
  •  孤街浪徒
    2021-01-25 23:21

    You can use replace() as hinted above. Using your regular expression for valid characters, you could try this:

    replace($string,"[^0-9a-zA-Z/\-\?:\(\)\.,'\+ \r\n]+","")
    

    You can see that your regular expression is almost as it was, except that ^ has been added to turn the set of valid characters to its complement.

提交回复
热议问题