NYCPHP Meetup

NYPHP.org

[nycphp-talk] A good PCRE expression for matching URLs

John Campbell jcampbell1 at gmail.com
Thu Jul 24 17:34:52 EDT 2008


On Thu, Jul 24, 2008 at 4:32 PM, Michael B Allen <ioplex at gmail.com> wrote:
> On Thu, Jul 24, 2008 at 2:37 PM, John Campbell <jcampbell1 at gmail.com> wrote:
>> On Thu, Jul 24, 2008 at 2:19 PM, Michael B Allen <ioplex at gmail.com> wrote:
>> What is the context for the matching?
>
> This will be used to pick out URLs in Creole Wiki markup. Which
> incedentally is not supposed to match characters that can occur
> naturally at the end of a sentence (,.?!:;"') so I guess I need to
> leave out '.' and ';' for my particular application.
>

Many urls contain a question mark.  Why not just accept anything
except a period or an question mark at the end?
 (http://|ftp://|mailto:).*?[\.\?]?\s

John C.



More information about the talk mailing list