Jump to content

very simple regex question for someone who just cant code


Recommended Posts

Hello,

I was hoping to find an answer here on this question:

 

I need to convert some urls dynamically with php:

http://www.domain.com/something-variable/12345/

into

http://www.domain.com/something-variable/12345/?xx=yy

 

the last two parts of the url are variable, and as you can see, the the url needs a variable string attached at the end. (always the same). I told you it was easy.

 

I found out that this could be done through a preg_replace command, and I tried, but i have no idea how to fix this.

I am not a developer you see.

 

Any help is appreciated.

 

Thanks,

Bert

 

 

The i makes the pattern case insensitive. The $1 and $2 represent capture groups one and two. Basically it will insert in their places the values captured in the pattern between the corresponding set of brackets. So $1 will be the first directory in the URI and $2 it's child directory.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.