Reputation: 1079
This is a a text: 6:0 FC Bayern Muenchen - Werder Brem
I want to have: FC Bayern Muenchen
My tries:
\s.*-
gives FC Bayern Muenchen -
\b\s.*\b-
doesn't match anything
Upvotes: 0
Views: 46
Reputation: 16948
Regex: /(?<![a-z ])[a-z ]+(?![a-z ])/i
, test it here: https://regexr.com/3vv2b
Explanation:
(?<![a-z ])
[a-z ]+
(?![a-z ])
Example in PHP:
if (preg_match_all('/(?<![a-z ])[a-z ]+(?![a-z ])/i', $test, $matches)) {
print_r($matches);
}
Output:
Array
(
[0] => Array
(
[0] => FC Bayern Muenchen
[1] => Werder Brem
)
)
Upvotes: 0
Reputation: 91430
Have a try with:
\s[^-]+
where [^-]
means any character that is not -
Upvotes: 1