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
Post a Comment