in reply to Re^3: Regex with multiple pattern omissions
in thread Regex with multiple pattern omissions
update:#!/usr/bin/perl -w use strict; my $input = '"non$volatile display" and ((timer oR count$3 Or display) + near5 hour).ccls. NOT (LCD).ab.'; my @omissions = qw(terms and or not with near same xor adj); my $omit = join("|",@omissions); $input =~ s/\..*?\.//g; $input =~ s/$omit//ig; my @searchterms = ($input =~ m/".+?"|[a-zA-Z][\w\$]+/gi); print "@searchterms"; #prints: #"non$volatile display" timer count$3 display hour LCD
As a general approach, I try to break these complex things into multiple easier steps. Get the right output, then tweak it if performance is not adequate.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Regex with multiple pattern omissions
by jhoop (Acolyte) on Jan 10, 2011 at 14:28 UTC |