Regular Expression doesn't match dot "." in a string

hello,

I am writting a regular expression that intend to match any tunnel or serial interface but it doesn't mtach any serial sub-interface.

For example, statement should match "Tunnel3" or "Serial0/1" but shouldn't match "Serial0\1.1" (doesn't include dot ".")

I tried the following but it doesn't work:
interface (Tunnel.*|Serial.*[^\.].)
interface (Tunnel.
|Serial[^\.]+)

Please advice.

Instead of Tunnel.* which will match any length and type of characters afterward, you could use
Tunnel[0-9]

It is all about matching, instead of not matching, therefore you have to make "Serial0/1" different than "Serial0\1.1"
In what ways are they different? Serial0/1 would have a space after it, or it would end the line. Serial0\1.1 doesn't.

Then Serial[0-4]/[0-9]([[:space:]]|$) will match Serial{0-4}/{0-9} but not Serial{0-4}/{0-9}.{0-9}

1 Like

Hello Aia,

I would like to thank you very much for your interest.

it works fine with me but now, I want RE to match "Serial0" or "Serial0/0" or "Serial0/0/0".

could you please help me to make this RE?

Thanks in advance,
Ahmed

Serial0[/0]*([[:space:]]|$) will match Serial0 or Serial0/0 or Serial0/0/0

1 Like