Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Current »

Interactive regex tutorial

If you want to dedicate a bit of time to learn regex, we recommend using this interactive regex tutorial:

Alternatively, check to the right for a regex cheat-sheet and below for some quick regex examples.

Regex search examples

Find any vlan with IDs 1020 or 1030:

vlan (1020|1030)

Find any vlan in the 10xx range:

vlan 10\d{2}

Find any router with OSPF router-id in


Make search case insensitive (will find 'VLAN 1002' or 'vlan 1002')

(?i)vlan 1002

Find all lines that start with 'hello' or 'helo' (multiple examples)



Find all lines that end with 'set', ignoring any trailing spaces


Regex cheat-sheet


.any single character
\dany number
\hany horizontal white-space (space, tab, etc.)


?one or zero times
*any number of times (even zero - zero or more times)
+at least once (one or more times)
{2}repeats 2 times
{2,4}repeats 2 to 4 times
\escape character
for example '\+' will look for a literal '+' sign


[abc]any of the characters inside ('a' or 'b' or 'c')

any of the characters inside the range (a through z)

()group - for example '(foo|bar)' - 'foo' or 'bar'
\escape character
for example '\(' will look for a literal '(' character


^start of text
if used with 'm' modifier - start of line

end of text
if used with 'm' modifier - end of line

Behavior modifiers (flags):

(?i)Case insensitive

'^' and '$' anchors work per-line instead of on the whole text
normally these modifiers would work on the whole text, using the 'm' modifier makes them per-line

  • No labels