Validating clipboard contents with contains command

I’m sure I’m missing something super simple here.

I’m trying to validate that the clipboard contents are correct user token. A correct token begins with "B$_".

This is what I’ve been attempting:


{if: contains(token, "B$_(.+)")}
{else}Oh no! It looks like the token is not copied to your clipboard properly.

Hi Peter,

The "contains()" function only works with plain text matches, it doesn't support regular expression syntax.

You want to use the "testregex()" function. Also you need to escape the "$" in the regex by putting a backslash before it as "$" has a special meaning in regular expressions, signifying the "end of the text".

Here's an example:


{if: testregex(token, "B\$_(.+)")}
{else}Oh no! It looks like the token isn't valid.

Aha! that works perfectly! Thanks Scott!