I am trying to confirm whether or not a string token is in and of itself an HTML or XML token. To match it must start with '<', and with '>' and have zero or more slash characters and one or more additional characters. There must be no additional '<' or '>' characters within the string. Examples of matching strings:
I have done this so far using the following regex:
Unfortunately, whilst this is generally OK it does not match the edge cases where the string starts and ends with a tag e.g.:
<b>This text will be displayed in bold</b>
So, how can I cause the regex to match only a single tag, and return no match if there is more than one tag in the string?
I am not necessarily stuck on using regex if there is a better alternative suggestion...