How to check Basepath to not have more than two levels

My requirement is to write a custom lint rule to not allow more than 3 levels in the base path.
For example, the base path cannot be longer than /v1/segment1/segement2/

I tried the following but did not work. Please suggest.
basepath_must_not_contain_more_than_two_levels:
enabled: true
summary: Base Path must not contain more than two levels. /v1/capability/sub-process or /capability/business-unit
type: style
then:
field: basePath
function: pattern
functionOptions:
notMatch: /{1,4}

Hi @maneesh.moota, you’ll want to update your notMatch to equal:

"notMatch": "^([^\/]*\/){3,}[^\/]*$"

Which checks for the presence of three forward-slashes in.

This worked for me.
se_basepath_must_contain_only_2_segments:
enabled: true
summary: Base Path must not contain more than two levels and cannot end with /. Eg. /v1/capability/sub-process or /v1/capability/business-unit
type: style
then:
field: basePath
function: pattern
functionOptions:
match: ^/[a-z0-9-](/[a-z0-9-])?(/[a-z0-9-])?*$