Using Regex to detect improperly formatted text

I am trying to craft a statement that will let me identity malformed text entered by my clients. A well-formed statement will look like the following:



{{<1 to 50 alpha characters and 0 to 5 numbers>}}



The statement I've come up with is the following, but it doesn't appear to work. There could be several of these statements in a block of text, but I want the detection to kick out after the first detected malformed tag. Any help would be appreciated.


{{(?![a-zA-Z]{1,50}(?::[d]{0,5})?}})|(?<!{{[a-zA-Z]{1,50}(?::[d]{0,5})?)}}(?::[d]{0,5})?)}}

Examples of good input would be:
{{test123}}
{{test}}

Examples of bad input would be:
{{123}}
{{test}
{test}}

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories