Regular expression for validating web site url

15 Apr

Readers interested in the most recent version of the XQuery and XPath Functions and Operators specification are encouraged to refer to

These functions and operators are defined for use in [XML Path Language (XPath) 2.0], [XQuery 1.0: An XML Query Language] and [XSL Transformations (XSLT) Version 2.0] and other related XML standards.

Although this seems like a trivial question, I am quite sure it is not :) I need to validate names and surnames of people from all over the world. If it were only English ones I think that this would cut it: I doubt that this is feasible - there are just to much Unicode symbols to exclude all unwanted symbols (and how will tell you what Chinese symbols to exclude?

) and there are surly to many valid symbols to inlcude them all (and you will have Chinese symbols problem again).

I would not put any constraints on a user name - it may even contain numbers; think of aristocratic names. No matter what regex you come up with, I can find a name somewhere in the world that will break it.

That being said, you do need to sanitize input, to avoid the Little Bobby Tables problem.