lobs has asked for the wisdom of the Perl Monks concerning the following question:
'George Washington' was the first President of the United States , the Commander-in-Chief of the Continental Army during the American Revolutionary War, and one of the Founding Fathers of the United States. He presided over the convention that drafted the current United States Constitution and during his lifetime was called the "father of his country".<ref name="Grizzard105"></ref> ...
Even with this I am having a lot of trouble with just extracting the first sentence. The closest I have gotten is with this code where $sent is the keyword I am searching(always the wiki articles itself), in this example we can say $sent=George WashingtonThis returned:if($doc =~ /'$sent' (is|was) ([\w]+[\s]*[,|;|"|'|\-]?[\s]*)+\./) { $reform = "$sent $1 $2.\n\nFOUND!!"; }
So can someone help me with my regex match please.if($doc =~ /'$sent' (is|was) (.*)\./) { $reform = "$sent $1 $2.\n\nFOUND!!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expression for Wikipedia Module
by Athanasius (Archbishop) on Apr 20, 2016 at 04:14 UTC | |
by lobs (Acolyte) on Apr 20, 2016 at 05:01 UTC | |
|
Re: Regular expresión for Wikipedia Module
by NetWallah (Canon) on Apr 20, 2016 at 04:32 UTC |