Sitecore, how to use regex pattern in parameter to search for script tags with FatalError

252 Views Asked by At

I'm currently trying to use the Parameters field to search for script tags but can't quite get it to work. The current Parameter I'm using is:

Pattern=^<script[^>]*>$&Text=Field "script" is not a valid entry.&Result=FatalError

This currently throws an error when my text field is <script>Test</script> which is wanted but it also throws an error when my text field is Test

I have tried other patterns including

Pattern=^<script>$&Text=Field "script" is not a valid entry.&Result=FatalError
Pattern=^<script[^>]*>(.*?)<\/script[^>]*>$&Text=Field....

The second pattern mentioned acts just like the first, no surprise there.

The third pattern doesn't throw any errors no matter what is entered into the text box.

1

There are 1 best solutions below

0
Matt.G On

Regex: <script[^>]*> should work for you

Usage: Pattern=<script[^>]*>&Text=Field "script" is not a valid entry.&Result=FatalError

The regex currently used are not working in your code as it uses anchors ^ (start of line) and $ (end of line).

^<script[^>]*>$ ^<script>$ ^<script[^>]*>(.*?)<\/script[^>]*>$