cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
7779
Views
10
Helpful
8
Replies

ASA Reg Expression Exact Match

HARIS_HUSSAIN
VIP Alumni
VIP Alumni

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.

8 Replies 8

Collin Clark
VIP Alumni
VIP Alumni

regex.png

 

Try ^https:\/\/yahoo\.com

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.

You can use the $ to match end of string.

--
Please remember to select a correct answer and rate helpful posts

@Marius Gunnerud.
Tried with $ but still 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.

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.

--
Please remember to select a correct answer and rate helpful posts

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#

possibly try with an * at the end:

"http://yahoo\.com*"

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card