Code:
$string = "Dilandau [Andreas Szabo] {Germany}"
$string = "Dilandau [Andreas Szabo] {Germany}"
<?php
$regex = '|(.+)\s+(\[.+\]\s*)?\{.+\}|';
$var = preg_replace($regex, '$1', $var);
?>
<?php
$string = "Dilandau [Andreas Szabo] {Germany}";
$test = explode(' ', $string);
echo $test[0];
?>
$string = "Dilandau[Andreas Szabo] {Germany}";
$test = explode(' ', str_replace(array('[', '{'), array(' ', ' '), $string));
echo $test[0];
<?php
$TXT = 'Dilandau [Andreas Szabo] {Germany}';
preg_match('~(.+)\b~U', $TXT, $array);
echo $array[0];
$TXT = 'Dilandau[Andreas Szabo] {Germany}';
preg_match('~(.+)\b~U', $TXT, $array);
echo $array[0];
$TXT = 'Dilandau-Andreas Szabo] {Germany}';
preg_match('~(.+)\b~U', $TXT, $array);
echo $array[0];
// etc...
?>
<?php
error_reporting(E_ALL);
$TXT = 'Dilandau uhu [Andreas Szabo] {Germany}';
preg_match('~(.+)\[~U', $TXT, $array);
echo $array[1];
// oder
echo strtok( $TXT, '[');
?>
Kommentar