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:

{token={clipboard}}

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

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:

{token="B$_ABC123"}

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

Aha! that works perfectly! Thanks Scott!