Using Regular Expressions Within the ASM Platform

Regular Expressions can be used to perform pattern matching on domain names within the ASM platform. The following examples provide examples of how Regex can be used effectively within ASM.

The ASM regex implementation uses the PERL programming language library.

General Examples of Regex within the ASM Platform

Top Domain Match

||https?:\/\/(www\.)?(a-zA-Z0-9-+\.)?co\.uk.*

This regex string matches on any site which has a top-level domain of co.uk.

(You can modify it to only look for .com top-level domains as well by replacing ?co\.uk.* with ?com.*.

Valid links: http://apicasystems.co.uk/\ , https://www.apicasystems.co.uk/\

Invalid links: www.apicasystems.co.uk , http://www.apicasystems.com/\

Exclude Top Domain

||https?:\/\/(www\.)?testing.apicasystems\.com\/.+

This expression looks for a second-level domain called testing.apicasystems and a top-level domain of .com. Anything after the link will not be matched.

Useful for excluding the root folder of a website but maintaining reporting for the rest of the site.

Valid link: https://testing.apicasystems.com/\

Invalid links: https://testing.apicasystems.com/home/\ , https://testing.apicasystems.com/file.php\

Exclude String


||((?!apicasystems).)*$

This regex string string looks for every word except for apicasystems.

Useful when a folder on the server is missing and it will take a while to fix.

Ignore External Site

||https?:\/\/(www\.)?(a-zA-Z0-9-+\.)?apicasystems\.com.((?!APIone).)*$

This regex string looks for something to skip, and also requires that apicasystems is in the string.

Say for example your site has a function called APIone, and you want to severity map any errors to APIone as information.

But a third-party website also has a function called APIone and if that function fails you want to get alerted by it.

With this string you can specify it to only look for errors on your site and ignore any other one.

Examples of Regex Within Severity Mapping

Regular Expressions can be used to customize Severity Mapping within a check configuration.

Skip and Keep

URL Pattern

Treat As Severity

URL Pattern

Treat As Severity

||https?:\/\/(www\.)?inside.example\.com\/.+

fatal

||((?!example).)*$

 warning

In this case, we are aware that the base domain inside.example.com always returns 403, so we want to ignore that, but catch errors in directories for the domain.

The first pattern will match an URL with the subdomain inside.example.com followed by something, for example, inside.example.com/home. If the URL is only the base domain the error will be ignored.

The second pattern matches the string example in URLs, and any errors not handled by the first pattern will generate a Warning.

Warn On Known Error

If you have an error occurring that you want to ignore, but still want to receive any other fatal errors:

 

URL Pattern

 

Treat As Severity

 

URL Pattern

 

Treat As Severity

||(?=.?\bexample\b)((?!fonts.googleapis).)$

 

 fatal

 

This pattern looks for example in the URL, and if it also contains fonts.googleapis, the error will be ignored.

Can't find what you're looking for? Send an E-mail to support@apica.io