How To Use Regex Negative Lookahead To Exclude Strings

Published Date Author: , Posted May 31st, 2019 at 1:20:12pm

I have a task in Perl to list specific files based on pattern match, those with and those without the string “_from_”.

There are two files in the directory to filter:

static-east.properties
static-east_from_west.properties

To capture the files with the _from_ string was easy:

To capture the files WITHOUT the _from_ string was not quite so easy until I learned about Negative Lookahead:

This is a great interactive regex testing site that I found (note: I have zero affiliation with them, I just think it is a great resource):
https://www.regextester.com/15

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.