Ask a Question related to PHP Development, Design and Development.
-
Wouter Van Vliet #1
RE: [PHP] Re: regex problem
So, what you want is to pretty much use this regex
/^(.*)([^\/]+)\/([^\/]+)$/
when matched on this URI, the backreferences will contain
\\1 partner/
\\2 name
\\3 contact.html
\\4 .html
I have not tested it, but I just guess it will work ;) Wanna know why? I'll> > partner/name/contact.html
tell you :D
- It first looks at the beginning of the string and will go on untill a the
next pair of () start (partner/)
- That happens there where there is a string containing any character, but
not a slash (partner)
- as a seperator another slash is added
- it starts to match the last part of the url and looks up untill the end.
Again a string containing no slashes
Hope it does do what I expect it to do .. ;)
Wouter
-----Oorspronkelijk bericht-----
Van: Merlin [mailto:news.groups@web.de]
Verzonden: vrijdag 15 augustus 2003 16:21
Aan: [email]php-general@lists.php.net[/email]
Onderwerp: [PHP] Re: regex problem
Good idea,
but does not work either - surprisingly! -
There should be a clean way with regex for this task.
Andy regex expert in here?
Merlin
"Kae Verens" <kverens@contactjuggling.org> schrieb im Newsbeitrag
news:20030815133157.45726.qmail@pb1.pair.com...use> Merlin wrote:> > ufff.. sorry guys, but I have to explain that better. I appreciate your
> > help, maybe I did not give enough info.
> >
> > I am trying to redirect with apache modrewrite. To do this you have tofrom> > regex (not if functions:-)
> >
> > My problem is, that there are member accounts which look like that:
> >
> > membername/contact.html
> >
> > and there are partner accounts which look like this:
> >
> > partner/name/contact.html
> >
> > The goal is to redirect only if it is a member account. If I put a
> > (.*)/contact.html it also matches the partner/
> > I tryed putting a root / infront, but there is not / root for the url>> > apaches point of view.
> >
> > So I would need a regex which will match the member account, but if the
> > first word is "partner" it should
> > not terminate.
> >
> > This seems to be a tough one!
> >
> ah - maybe a chain of rewrites would do?
>
> send all matches of /^partner\/(.*)\/contact.html$/ to partner\/\1\/blah
> send all matches of /^(.*)\/contact.html$/ to NEWLOCATION
> send all matches of /^partner\/(.*)\/blah$/ to partner\/\1\/contact.html
>
> Kae
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Wouter Van Vliet Guest
-
Regex problem
Hi there, I have a regex problem. Basicly I do not want to match: /dir/test/contact.html But I do want to match: /test/contact.html -
Regex - Problem
Hello! I have this RegEx: /(+:\/\/+)/i Now, I want to exlude on the end of a String the formats .gif / .jpg / ..png / .exe / .zip / .rar ... -
[PHP] regex problem
* Thus wrote Merlin (news.groups@web.de): I'm not sure what you expect since this *is* a php mailing list. Mod rewrite is a powerful tool and... -
[PHP] regex problem
So ^+/* or ^!(partner/) Merlin wrote: -
[PHP] regex problem
That's if($string == 'test/contact.html') of course... :) it could be if($string == "test/contact.html")



Reply With Quote

