Answer the question
In order to leave comments, you need to log in
How to strip the title from the string [:en]Black Brown[:de]Black Brown[:]?
There is this line: [:en]Black Brown[:de]Black Brown[:]
. What is an easy way to get 1 title Black Brown
?
Answer the question
In order to leave comments, you need to log in
$str = '[:en]Black Brown[:de]Black Brown[:]';
preg_match('/\[:en\]([^(\[:)]*)/', $str, $matches);
$str_en = $matches[1] ?? '';
echo $str_en;
Replace all occurrences of \[.*?\] with an empty string
$str = '[:en]Black Brown[:de]Black Brown[:]';
$newStr = preg_replace('#\[:[a-z]*\]#is', '', $str);
var_dump($newStr); // 'Black BrownBlack Brown'
or, if readable words are needed, to a space, then remove whitespace characters from the beginning and end of the line (using the function trim()
) Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question