James's Blog
Sunday, December 04, 2005
Perl: Find the Nth Occurrence of a match
while(/(\w+)\s+fish\b/gi){
if(++$count == $WANT){
# do what ever you want to do
}
}
\w+ match a word
\s+ 1 or n space
\b word boundary
/g gloal match/substitue as often as possible.
/i ignore case
posted by James Pei @
9:39 PM
0 Comments:
Post a Comment
<< Home
Previous Posts
Perl: match numbers
Perl: difference between + and *
Perl: transaction across databases
Quick Sort
Oracle: Choosing Index Keys
Oracle: Flashback Query in 10g
Oracle: Links
Oracle: Flashback
Oracle: Using Loop and Random
Oracle: Histograms
0 Comments:
Post a Comment
<< Home