c# - Regular expression for quoted text and special characters -


i'm trying figure out regular expression in .net can detect xml special characters enclosed in quotation marks. can contain other characters @ least 1 ocurrence of following has exist < > & ' "

matches

"hello &" "& something" "testing <>" 

does not match

"foo bar" 

i've tried expressions "[&<>\"\'\w\s]+" regex accepts strings special characters absent.

the purpose of expression cleanse xml attributes special characters might crash parsers.

your regex says string of of characters (e.g. \w) should match. try instead:

    ^.*[&<>\"\'].*$ 

you shouldn't need escape quotes, though.

and hope you're using dom parser retrieve attribute values...


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -