Green rep up for grabs for the first to give me working code that replaces: [::anything here::] with empty space i.e. removes it from $string. Between the 'opening tag' [:: and the 'closing tag' ::] can be any case alpha numeric and the usual _ - @. Between those tags is an unknown amount of characters and spaces are possible. So: $string = "The dog was walking [::special shite-here::] on the street." Becomes: $string = "The dog was walking on the street." (That actually leaves one space too many, if you wipe that as well you're star.) I suck at RegExps. Thanks!
This is how I would do it in Perl: my $string = "The dog was walking [::special shite-here::] on the street."; $string =~ s/\s?\[::(.*?)::]\s?/ /g; Code (markup): This also saves the data between the tags in the variable $1
maybe something like: preg_replace( "/\s?\[::(.*?)::]\s?/", " ", "The dog was walking [::special shite-here::] on the street." ); Code (markup): It's just a guess though, I don't venture into PHP much, mostly Perl and Javascript these days.
I suck at regxps myself so i'd just use. $myStr = "The dog was walking [::special shite-here::] on the street."; $start = strpos($myStr,"[::") + 3; $end = strpos($myStr, "::]"); $total = $end - $start; $temp = substr($myStr, $start, $total); $myStr = str_replace("[::".$temp."::]"," ", $myStr); Code (markup): Sorry, couldn't resist writing it. :-/
LOL, that's what I would do as well but I dislike longwinded ugly code more and more hence the RegExp whish. I'll use it for the time being