NYCPHP Meetup

NYPHP.org

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

John Campbell jcampbell1 at gmail.com
Thu Jul 24 14:37:02 EDT 2008


On Thu, Jul 24, 2008 at 2:19 PM, Michael B Allen <ioplex at gmail.com> wrote:
> Does anyone have a good PCRE for matching URLs?
>
> Or perhaps someone can improve (or correct) the expression I'm using currently:
>
>  $expr = '[a-zA-Z0-9]{1,10}://[a-zA-Z0-9.-]+[\p{L}/~._-]*|mailto:[a-zA-Z0-9\\@.-]+';
>

I am not sure I completely understand what you are trying to do, but
it doesn't look like you are matching + or %.

What is the context for the matching?

-John C.



More information about the talk mailing list