d_brown3 has asked for the wisdom of the Perl Monks concerning the following question:
I have this code and I need to return the first five words
of the string returned in $2 by the first regular expression.
The file is an xml file with a huge chunk of CDATA that contains
a number of editorials split by <p> tags.
while (<INFILE>) { if (/(<editorialtext><!\[CDATA\[|<p>)(.*)(\]\]><\/editorialtext|$) +/) { my $editorial = $2; my $headline = $2; $editorial =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs; } }
Originally posted as a Categorized Question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I return the first n words of a string?
by Fastolfe (Vicar) on Oct 26, 2000 at 18:59 UTC | |
Re: How do I return the first n words of a string?
by Anonymous Monk on Apr 16, 2002 at 13:27 UTC | |
Re: How do I return the first n words of a string?
by princepawn (Parson) on Oct 26, 2000 at 20:23 UTC | |
Re: How do I return the first n words of a string?
by runrig (Abbot) on Oct 26, 2000 at 20:18 UTC |
Back to
Seekers of Perl Wisdom