01-09-2019 06:55 AM - edited 02-21-2020 08:38 AM
I am trying to build ASA regex which will match only if the URL Is exactly https://yahoo.com
But it is also matching https://yahoo.co or https://yahoo etc
ciscoasa# test regex "https://yahoo.com" "https://yahoo.co"
INFO: Regular expression match succeeded.
ciscoasa# test regex https://yahoo.com https://yahoo\.com
INFO: Regular expression match succeeded.
ciscoasa#
ciscoasa#
ciscoasa# test regex https://yahoo.com https://yahoo\.co
INFO: Regular expression match succeeded.
ciscoasa# test regex https://yahoo.com https://yaho
INFO: Regular expression match succeeded.
Is there way to specify End of String like we can use ^ to specify beginning of string.
01-09-2019 07:11 AM
01-09-2019 12:30 PM
Try ^https:\/\/yahoo\.com
01-09-2019 10:20 PM
Nope Not Working
ciscoasa(config)#
ciscoasa(config)# test regex https://yahoo.com ^https:\/\/yahoo\.com
INFO: Regular expression match succeeded.
ciscoasa(config)# test regex https://yahoo.com ^https:\/\/yahoo\.c
INFO: Regular expression match succeeded.
ciscoasa(config)# test regex https://yahoo.com ^https:\/\/yahoo\.com$
INFO: Regular expression match failed.
ciscoasa(config)# test regex https://yahoo.com ^https://yahoo.com$
INFO: Regular expression match failed.
ciscoasa(config)# test regex https://yahoo.com ^https://yahoo.com\$
INFO: Regular expression match failed.
01-09-2019 01:16 PM
You can use the $ to match end of string.
01-09-2019 10:21 PM
01-10-2019 01:51 AM
It looks like you are testing incorrectly. You are changing the regex expression instead of the URL you are matching against.
ASA3# test regex https://yahoo.com ^https:\/\/yahoo\.com
INFO: Regular expression match succeeded.
ASA3# test regex https://yahoo.co ^https:\/\/yahoo\.com
INFO: Regular expression match failed.
ASA3# test regex https://yahoo ^https:\/\/yahoo\.com
INFO: Regular expression match failed.
ASA3# test regex yahoo.com ^https:\/\/yahoo\.com
INFO: Regular expression match failed.
01-10-2019 04:50 AM
Dear Marius,
Still the issue is that we cannot define End of String.
So if there is any test after the string still it will match as below.
ciscoasa#
ciscoasa# test regex http://yahoo.com/a "http://yahoo\.com"
INFO: Regular expression match succeeded.
ciscoasa# test regex http://yahoo.com/test "http://yahoo\.com"
INFO: Regular expression match succeeded.
ciscoasa# test regex http://yahoo.co "http://yahoo\.com"
INFO: Regular expression match failed.
ciscoasa#
08-23-2020 11:35 PM
possibly try with an * at the end:
"http://yahoo\.com*"
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide