in reply to Re: refine regex
in thread refine regex
step 6. Test it! - it was necessary to add a small fix:
#/usr/bin/perl use strict; use warnings; my $string_original =<< "END"; ("Immunologic and Biological Factors"[MESH] OR "Immunosuppressive Agen +ts"[MESH] OR "Transplantation Immunology"[MESH] OR "Allergy and Immun +ology"[MESH] OR "Graft vs Host Disease"[MESH]) NOT ("Foo"[MESH] OR "B +ar"[MESH]) AND ("Kidney Transplantation"[MESH] OR "Liver Transplantat +ion"[MESH] OR "Heart Transplantation"[MESH]) NOT ("My Term"[MESH] OR +"Blah"[MESH]) NOT "foobar"[MESH] END # original { my $string = $string_original; $string =~ s/ NOT ".*?"\[MESH\] ?//g; $string =~ s/ NOT \(.*?\) ?//g; print $string, "\n"; } # Corion's { my $string = $string_original; $string =~ s! NOT (?:".*?"\[MESH\]|\(.*?\)) ?!!g; print $string, "\n"; } # fixed { my $string = $string_original; $string =~ s! ?NOT (?:".*?"\[MESH\]|\(.*?\)) ?!!g; print $string, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: refine regex
by ikegami (Patriarch) on Nov 26, 2004 at 14:49 UTC | |
|
Re^3: refine regex
by rsiedl (Friar) on Nov 26, 2004 at 11:58 UTC |