Vinoth Babu
Vinoth Babu

Reputation: 6852

REGEXP not allowing single character at the starting

I am using the following regexp for XSS attack validation. Its checking <..> </> datas correctly. But when I type single character at first its not allowing any single character (eg: if I type 'a' its not allowing). Can anyone help me on this?

/^(|\/|[^\/>][^>]+|\/[^>][^>]+)$/

Upvotes: 0

Views: 52

Answers (1)

Gilles-Antoine Nys
Gilles-Antoine Nys

Reputation: 1481

Despite the fact that Regex is not optimal for XSS attack validation as comments said :

This regex need at least two characters because of the two +, which means between one and unlimited characters. * can be used to specify between zero and unlimited characters.

Upvotes: 1

Related Questions