in reply to IP Filtering RegEx needed

You need to quote the meta characters in the regex with \Q and \E. Otherwise you need to escape the meta-characters (such as [ and .) with backslash (\).

Here's an example:
#!/usr/bin/perl -w use strict; my $grp = qr/\[\d+-\d+\]/; for (<DATA>) { print if /\d+\.\d+\.$grp\.(\d+|$grp)/; } __DATA__ 123.145.[146-149].2 135.168.[10-115].[0-125] 135.168.12.[0-125]


Update:
Sorry I misread the question. If you are after a single regex to do range checking, you can use the match time interpolation technique.
#!/usr/bin/perl -w use strict; my $grp = qr/^123\.145\.(\d+)\.(\d+)$(??{ $1 >= 146 && $1 <= 148 ? '' +: 1})/; for (<DATA>) { print if /$grp/; } __DATA__ 123.145.130.3 123.145.146.3 123.145.147.3 123.145.148.3 123.145.149.3