Regex and the String Between the Colons

Published by Torry Crass on

After working on this for a bit I wanted to make sure I posted this reminder for myself and others.

Regex is a very powerful tool but the syntax is almost something of an art. I needed to identify strings of numbers between two colons. The following regex should look at a string such as…

asdfg:34234:bdfj

And will allow selection of: :lkj23jdf:

That regex string is: :.*[0-9]:

Caveats include, this requires at least two, and no more than three colons in a file, chances are, if you have a colon separated file with a lot of fields, this may not be your ideal solution but maybe its a start. If someone has a more holistic (simple) solution to parse out such files feel free to share.


0 Comments

Leave a Reply