Hi there,
I have a script called sitemap_ (that's right, sitemap with _ on the end and no extension).
I am detecting any parameter (REQUEST_URI) after the sitemap_ either in the form
sitemap_X
sitemap_X_Y
can anyone tell me what regex I use to determine whether it is of either type, and if so, what X and Y are in the string?
Many thanks
Mark
regex for this simple string please
Moderator: General Moderators
- thomas777neo
- Forum Contributor
- Posts: 214
- Joined: Mon Mar 10, 2003 6:12 am
- Location: Johannesburg,South Africa
You don't necassarily need to use regex.
You could probably use one of these functions:
split
explode
substr
strlen
Or a comination thereof to get X or Y, if I understand the question correctly.
e.g.
Just a simple non generic example of how you can manipulate strings.
feyd | Please use
You could probably use one of these functions:
split
explode
substr
strlen
Or a comination thereof to get X or Y, if I understand the question correctly.
e.g.
Code: Select all
<?php
$url = "blah_x_y";
$breakup = explode("_",$url); // turns $breakup into an array ("blah","x","y")
$default = $breakup[0]; // blah
$x = $breakup[1]; // x
$y = $breakup[2]; // y
?>feyd | Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia