RE: Regex help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Jason Pruim [mailto:japruim@xxxxxxxxxx]
> Sent: Tuesday, September 09, 2008 7:30 AM
> To: PHP-General List
> Subject:  Regex help
> 
> Hey everyone,
> 
> Not completely specific to php but I know you guys know regex's
> better then I do! :)
> 
> I am attempting to match purl.schreurprinting.com/jasonpruim112 to
> purl.schreurprinting.com/p.php?purl=jasonpruim112
> 
> Here are my current matching patterns:
> 
>                  RewriteRule /(.*) "/volumes/raider/webserver/
> documents/dev/schreurprinting.com/p.php?purl=$
> #               RewriteRule /(*.) "/purl.schreurprinting.com/$1"
> #               RewriteRule /(mail.php?purl=*) "/
> purl.schreurprinting.com/mail.php?purl=$1"
> 
> Yes I am doing this for apache's mod_rewrite, but my question is much
> more specific to regex's at this point :)
> 
> Any ideas where I am going wrong? it seems like it should be fairly
> simple to do, but I don't know regex's at all :)

http://www.regular-expressions.info ... that's how I learned. :)
Anyway... your match might be something like:

^/([^/\.]+)/?$

And the rewrite...

"/p.php?purl=$1"

To break it down, the match is looking for "The beginning of the line,
followed by a forward slash, followed by (begin capture group) 1 or more
characters that are not a forward slash or a period (end capture group)
followed by an optional forward slash, followed by the end of the line."

The rewrite is fairly straightforward.

I went 100% generic with the match due to your following e-mail that
stated "jasonpruim112" could be any username. If "112" is necessary for
the match, it would be more like:

^/([^/\.]+112)/?$

Hope this helps,


Todd Boyd
Web Programmer




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux