#/usr/bin/perl use strict; use warnings; my $string =<< "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 # This removes all instances of 'NOT "anything"[MESH]' $string =~ s/ NOT ".*?"\[MESH\] ?//g; # This removes all instances of 'NOT (anything)' $string =~ s/ NOT \(.*?\) ?//g;
In reply to refine regex by rsiedl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |