yes i know that the example i wrote above was for checking if an e-mail is valid
and i know how to use the preg_match function but my question is what are the patterns that’s equivalent to the htaccess codes which i can use in the preg_match function ??
well thank you but i already know that, actually every php beginner knows that
my question is what is the pattern that’s equivalent to this code “([^/]+)”, this code “([^/]+)/p([0-9]+).html”, and so on.
i just want to redirect all the links to the test.php file which in turn match the requested link to the exact pattern i want then send data which i got from the link pattern to another page. like in vbseo plugin all links are redirected to the vbseo.php file.
Are you saying you want PHP to redirect the user depending on the value of $_GET[‘url’], and the pattern you are looking to match is something like p123.html ?
If that is not what you mean, then try and spend a bit more time and attention in giving us an actual specific example of what you do want, and maybe someone will be able to help you out.
Im not pissed off, but I am getting exasperated because I fail to understand your problem. Dont worry, a forum is sometimes not the best method for getting ideas across – time lags, language differences etc.
Let’s try this:
Give us a concrete example of a value that $_SERVER[‘REQUEST_URI’] would hold (just make one up that typifies your problem).
Then explain what the regex has to extract from that - don’t describe it in terms, show us exactly the text or decision that has to be extracted from that $_SERVER[‘REQUEST_URI’]
Is a valid preg_match pattern, which reads “One or more of anything that isnt a /, followed by a /”.
How to decode it:
() is a subpattern. the / on the end is a literal /. So we’ve dealt with those. Remaining pattern: [^/]+
is a character class. + after a character class means “One or more of the preceding class”.
^ at the beginning of a character class means “negate the class”
the / is again a literal /.
So now that you’ve broken it down, build it back up:
^/ “Not a slash.”
[^/]+ “One or more not-a-slash-es”
([^/]+)/ “One or more not-a-slashes followed by a slash.”, which, reworded, is “One or more of anything that isnt a /, followed by a /”.
i want to use the preg_match function to match the requested url to an exact pattern that is
/category/topic1/topic-name.html
and if it matches this pattern the test.php file sends the variables (that i extract from the url such as $category,$id and $name) to another file which has the query codes
Great One, this is my pattern
when i copied the code it gave me an error then i realized that REQUEST_URI is missing the U ;), anyway it’s working
many thanks <3 <3