Jump to content

[SOLVED] Finding the question mark


Jesper

Recommended Posts

Hey guys,

 

For my latest project, I need to find the something in an expression. The expression is:

gamenieuws/([0-9]+)/?.*

The problem is that at the end of the expression there can be another GET variable, so it would end with something like ?&var=val. I don't want to replace this with the regexp. I've managed so far to find the question mark, but it replaces the string until 1 char before the ?, instead of it replaces it until the ?.

 

My regexp is now:

gamenieuws/([0-9]+)/?(.[^\?])* ?item=$1

 

 

The problem

It might be hard to understand, and I find it hard to explain as well. Anyways, this is what I want:

Find gamenieuws/([0-9]+)/.*, but then I want to pass on the get variables as well. For example, I want

gamenieuws/123/Lorem-Ipsum-Dolor-Sit-Amet.html?&val1=25&val2=4
to become
?item=123&val1=25&val2=4
.

 

Could anyone help me with how to do this, because I've been trying for very long and I have no idea :P.

 

 

Thanks in advance,

 

Jesper

Link to comment
https://forums.phpfreaks.com/topic/161168-solved-finding-the-question-mark/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.