Quantcast
Channel: THWACK: Message List - Network Configuration Manager
Viewing all articles
Browse latest Browse all 8827

Re: a simple find expression using '*' and '?'

$
0
0

They tend to use pretty standard regular expressions, so if you search for a regex cheat sheet, you should find a good example.   I use one from AddedBytes.com.   That being said, regex's can be tricky...  For the simple string find, I do believe that "*" matches any number of  anything, while "?" matches one of something.   Only count on using the "*" once in any given line.

 

That being said, I choose to use a regex for matching our banner, worked out best that way.   My regex converted to your use case above, would look something like this (I'm counting on # not being a meta character that needs to be escaped, I don't believe it is).

 

banner motd\s*\^C

#+ COMPANY #+

\s*

Unauthorized users will be prosecuted to the fullest

extent of the law.

\s*

Contact network@company.comor call \(555\) 555-1212 to

report trouble associated with this equipment.

\s*

#+ COMPANY #+

\^C

 

Brief explanation, ^, ( and ) are a meta-character that needs to be escaped with a \.   '\s*' just says any number of spaces can be here (even none).  #+ just says there should be one or more '#''s there.   Hope this works, might need some tweaking.  I did get mine working with something similar


Viewing all articles
Browse latest Browse all 8827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>