[Gmail-Lounge] Re: php questions
On 12/2/05, Allen Day <so.orange@gmail.com> wrote:
> >from the looks of it, you're escaping the escape for the dot before
> >user.... so replace \\.user with \.user
>
> Backslashes can get really ugly in regex in code. Anyway, since the . is
> literal it has to be escaped -- but since a backpspace is an escape within
> php, you need to escape the escape itself in order for it to be literal in
> php (to escape the dot) -- that said, the escapes need to be doubled up.
> So it would be preg_match('/([0-9]+?)\\.user\\.js/',$file,$time);
uhmmmmm... yeah, I forgot about that... I've been meddling with the
mod_rewrite regexes lately and haven't used the PHP sort for a
while... I forgot about PHP string escaping
> >regexes in PHP need to be started and ended with the same character...
> >if you need that character in the regex, use some other -- / \ |... I
> >can't think of any others right now but {} works too ({ for the start
> >and } for the end)
>
> You can always just escape the / if you need it within the regex. I think
> basically any character will work by the forward slash is the most common.
I once ran into trouble with that and could not get the escaping to
work properly, so I just gave up and used {}...
(don't ask me what happened and how many people I buried in the back
yard once I found out I had to match curlies as well)
> Two basic implementations, and all sorts of variations thereof ;)
it's the variations that piss me off... the difference between Windows
and Linux implementations of regex libraries for apache (mod_rewrite)
come to mind... 4am on a sunday (well, that's technically monday) also
come to mind... and lots and lots and lots of coke... and waking up 5
hours later to let that coke get on with the circle of life...
> Indeed. Why go simple when you can go with power? ;)
> Now, if only it worked the power would be obvious! :-)
I can't believe how you summed up everything I hate about Linux in two
sentences... awesome
--
So low the sky is all I see
All I want from you is forgive me
So you bring this poor dog in from the rain
Though he just wants right back out again
0 Comments:
Yorum Gönder
<< Home