Forum Moderators: coopster

Message Too Old, No Replies

Getting URI junks with Regular Expressions

How can I get the last URI junk with R.E.?

         

asantos

6:29 pm on Mar 13, 2006 (gmt 0)

10+ Year Member



Suppose i have this relative URL:
/about_us/employees/

In the cms im developing, it is supposed that the article can be translated from english to french if i do this:
/about_us/employees/_fr

or to spanish if i do this:
/about_us/employees/_es/

note that it must be recognized be with or without the final '/'... i've setup an htaccess file which delivers all the data to index.php, which handels the REQUEST_URI variable.

So, i need to make a regular expression check to the REQUEST_URI variable to see if someone typed _XX or _XX/ at the end of it.

Help?

jbrevell

5:21 pm on Mar 14, 2006 (gmt 0)

10+ Year Member



How about:

<?
$d[] = '/about_us/employees/';
$d[] = '/about_us/employees/_fr';
$d[] = '/about_us/employees/_es/';
$d[] = '/asdasd/asd~asd/sdds';
$d[] = '/about_us/employees/_ES/';
$d[] = '/about_us/employees/_Es/';

foreach ($d as $val){
if (eregi("_[a-z]{2}/{0,1}$",$val)) echo "$val: matched<br>";
else echo "$val: not matched<br>";
}
?>