Reputation: 3
This regex is used to check some user input:
/^[^<">]*$/
What is it checking for?
Upvotes: 0
Views: 206
Reputation: 8647
Matching a string against this RegEx will return FALSE if any double-quotes or brackets exist in the string. If none exist, or the string is empty, it will return TRUE.
Upvotes: 0
Reputation: 39057
/^[^<">]*$/
To be clear: it does not match any string that contains <, >, or ".
It will match anything else.
Upvotes: 1
Reputation: 106392
It ensures that the input contains no <
"
or >
characters.
^
at the beginning matches the literal beginning of the string.
[^<">]*
matches 0 or more characters that ARENT one of the three: <">
.
$
at the end matches the literal end of the string.
Upvotes: 2
Reputation: 12867
This is probably a simple regex being used to check for an xml element with an attribute.
Upvotes: -2
Reputation: 192015
It's checking for double quotes ("
) and angle brackets (<>
).
/^[^<">]*$/
/^
means the start of the string.
[^<">]
means not <
, "
, or >
.
*
means zero or more of the previous expression.
$/
means the end of the string.
So it's checking whether the input consists of zero or more characters, none of which are <>"
.
Upvotes: 7
Reputation: 91349
It's checking for a line (possibly empty) that doesn't contain <, > or ".
Upvotes: 10