Regular expression '<>' validation
regex
Solution
You'll need to add beginning (`^`) and end (`$`) anchors to your expression to ensure that only the pattern you specified is allowed:
^([a-zA-Z0-9]+)|((https?://)?([\w-]+\.)+[\w-]+(/[-\w ;,./?%&=]*)?)$
Problem
I'm currently working on building a regular expression that will accept URL's and hostnames. So the following should be accepted: ``` google google.com www.google.com http://google.com http://www.google.com ``` However what should not be accepted is: ``` <xml> <html> ``` The expression I've got so far is: ``` ([a-zA-Z0-9])|((http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&=]*)?) ``` However this part of the expression: `([a-zA-Z0-9])` matches on `<xml>` and `<html>` Anyone any suggestions as to what I'm missing here?