tech stuff.

Debugging regex from the CLI

leave a comment »

Just stumbled across this obvious solution from the why didn’t I realize this earlier? department. GNU grep makes an great regex debugger!

The secret is combining -P (for perlre) with --color to color the matched pattern. For example:

% echo -e '123\n123.123' | grep -P '^\d+(?!\.\d)'
% echo -e '123\n123.123' | grep -P '^\d+(?![\.\d])'

Written by Lee Verberne

2017-02-21 at 12:43

Posted in Uncategorized

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: