in reply to regec to select text ather than remove HTML tags

that did not work I want the follwing combinations to be selected <hello hello> hello but not <hello> thanks for your help
  • Comment on Re: regec to select text ather than remove HTML tags

Replies are listed 'Best First'.
Re^2: regec to select text ather than remove HTML tags
by Anonymous Monk on Jan 23, 2012 at 12:41 UTC

      The code seemed to work for me.

      Using pm_txt.txt for input for pm_regex.pl pm_txt.txt

      1.hello> 2.<hello 3.hello <hello>

      pm_regex.pl

      use strict; use warnings; my $filename = shift or die "Usage $0 FILENAME\n"; open my $fh, '<', $filename or die "Could not open '$filename'\n"; while (my $line = <$fh>) { chomp $line; if ($line =~ /^\d+\..*?(hello).*$/) { print "In $line $1 matches\n"; } else { print "$line doesn't match\n"; } }

      Running perl pm_regex.pl pm_text.txt produced the output:

      In 1.hello> hello matches

      In 2.<hello hello matches

      In 3.hello hello matches

      <hello> doesn't match

        Please go to http://regexpal.com/ In java script, I need only a regex that I can use as a condition in my software.