Greetings,
Does anyone have any experience with Regular Expressions?
I usually use very simple Regular Expressions for my work, however I've been
trying to create a plugin for my church's website that will link all bible
references to the bible extension that I have installed.
I've managed to match the bible references correctly, however it is also
matching non bible references too, because it is not matching whole words
only. For example, it matches *blahluke 1*.
I've tried to use the Word boundary *\b* and a Negative lookbehind for chars
*(?<![a-zA-Z])*, but they do not seem to work.
My REGEX:
preg_match_all('/(?<reference>(?<book>('.*$booksRegex*
.'))\s(?<chapter>[0-9]{1,3})(:|\.)?(?<versefrom>[0-9]{1,3})?(?<separator>[,-]+)?(?<verseto>[0-9]{1,3})?)?/i',$row->text,$matches);
Where *$booksRegex* is a PHP variable containing all bible books and
possible abbreviations in Portuguese:
gênesis|exodo|levítico|números|deuteronômio|josué|juizes|rute|1 samuel|2
samuel|1 reis|2 reis|1 crônicas|2
crônicas|esdras|neemias|ester|jó|salmos|salmo|provérbios|eclesiastes|cantares
de salomão|canticos dos canticos|isaías|jeremias|lamentações de
jeremias|lamentações|ezequiel|daniel|oséias|joel|amós|obadias|jonas|miquéias|naum|habacuque|sofonias|ageu|zacarias|malaquias|mateus|marcos|lucas|joão|atos|atos
dos apóstolos|romanos|1 coríntios|2
coríntios|gálatas|efésios|filipenses|colossenses|1 tessalonicenses|2
tessalonicenses|I timóteo|II timóteo|tito|filemom|hebreus|tiago|1 pedro|2
pedro|1 joão|2 joão|3
joão|judas|apocalipse|genesis|exodo|levitico|números|deuteronomio|josue|juizes|rute|I
samuel|II samuel|I reis|II reis|I cronicas|II cronicas|I samuel|II samuel|I
reis|II reis|I cronicas|II
cronicas|esdras|neemias|ester|job|salmos|proverbios|eclesiastes|cantares de
salomao|isaias|jeremias|lamentacões de
jeremias|lamentacões|lamentacoes|ezequiel|daniel|oseias|joel|amos|obadias|jonas|miqueias|naum|habacuque|sofonias|ageu|zacarias|malaquias|mateus|marcos|lucas|joao|atos|atos
dos apostolos|romanos|1 corintios|2 corintios|I corintios|II
corintios|galatas|efesios|filipenses|colossenses|1
tessalonicenses|1tessalonicenses|2 tessalonicenses|2tessalonicenses|I
tessalonicenses|Itessalonicenses|II tessalonicenses|IItessalonicenses|1
timoteo|1timoteo|2 timoteo|2timoteo|Itimoteo|Itimoteo|II
timoteo|IItimoteo|tito|filemom|hebreus|tiago|1 pedro|1pedro|2 pedro|2pedro|1
joao|1joao|2 joao|2joao|3 joao|3joao|I pedro|II pedro|I joao|II joao|III
joao|judas|apocalipse|gn|ex|lv|nm|dt|js|jz|rt|1sm|2sm|1rs|2rs|1cr|2cr|Ism|IIsm|Irs|IIrs|Icr|IIcr|ed|ne|et|jó|sl|pv|ec|ct|is|jr|lm|ez|dn|os|jl|am|ob|jn|mq|na|hc|sf|ag|zc|ml|mt|mc|lc|jo|at|rm|1co|2co|Ico|IIco|gl|ef|fp|cl|1ts|2ts|1tm|2tm|Itm|IItm|tt|fm|hb|tg|1pe|2pe|1jo|2jo|3jo|jd|ap
Thanks in advanced.
Best regards,
Douglas Machado
"*... For I know the plans I have for you," declares the LORD, "plans to
prosper you and not to harm you, plans to give you hope and a future...*"
The only God - Jeremiah 29:11
[image: Ideal Joomla Extensions] <http://ideal.fok.com.br/> [image:
JED]<http://extensions.joomla.org/extensions/owner/machadoug>
[image: LinkedIn]
<http://br.linkedin.com/pub/douglas-machado/a/188/825/> [image:
I'm
Sabbatarian]<http://www.seventhdaybaptist.org/7DB/Sabbath_EN.asp?SnID=575766069>
_______________________________________________
New York PHP SIG: Joomla! Mailing List
http://lists.nyphp.org/mailman/listinfo/joomla
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php