Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mizeweb

Pages: [1]
1
Programming / Re: working with string patterns...
« on: September 13, 2016, 06:28:21 AM »
my second example in my first post works now, i forgot:
[0]

so here is version as "function":

function special_rtrim($string){
  
preg_match_all('#\([^\)]*\)#'$string$matches);
  
$last_match array_pop($matches[0]);
  
$string preg_replace('#\('.$last_match.'\)#' ,"",$string);
return 
$string;
}

//$string="This is my data (want to keep this data) (want to delete this data and brackets)";
$string="this is another test #3 (2012) (september) (get rid of me data)";  //needs to become "this is another test #3 (2012) (september)"
//$string="this is test#1 (2012) (delete this data)"; //needs to become "this is test#1 (2012)"
//$string="this is some data test#2 (data to delete)"; //needs to become "this is some data test#2" 

$string special_rtrim($string);
 
echo 
$string;


mfg Andi

thats so good thanks

Pages: [1]