Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: regec to select text ather than remove HTML tags

by lutok (Scribe)
on Jan 23, 2012 at 23:38 UTC ( #949547=note: print w/ replies, xml ) Need Help??


in reply to Re^2: regec to select text ather than remove HTML tags
in thread regec to select text ather than remove HTML tags

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


Comment on Re^3: regec to select text ather than remove HTML tags
Select or Download Code
Replies are listed 'Best First'.
Re^4: regec to select text ather than remove HTML tags
by Veer (Initiate) on Jan 24, 2012 at 04:03 UTC
    Please go to http://regexpal.com/ In java script, I need only a regex that I can use as a condition in my software.

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

      So you're looking for a javascript regex?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://949547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (20)
As of 2015-07-29 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls