0

I want to delete lang-code(EN/DE/FR/IT/JA/ES) out of a string but i dont know the right expression can someone help me ? the Lang-code string always starts with EN/ and the end is variable i know i can delete this with preg_match but i diddnt understand the regex expressions... my code so far:

$string = 'some string EN/DE/FR/IT/JA/ES some string' 
$new_string = preg_match('/ - (.*?)/', $string, $match);
$final_string = str_replace ($match[1], '', $new_string);

$final_string should return 'some string some string' does someone know the right expression for preg_match and can help me to understand regex a little more?

LeGerman
  • 23
  • 1
  • 5
  • I suggest you to follow some tutorials about RegExes, Stackoverflow isn't a substitute to a learning platform. Giving you the correct pattern keys in hand won't help you neither, because you'll be stuck when you'll have to maintain it – Cid Sep 29 '22 at 11:17
  • 1
    Does this answer your question? [Reference - What does this regex mean?](https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – Cid Sep 29 '22 at 11:18
  • Thank you @cid https://stackoverflow.com/a/22944075/14619937 - helped me alot – LeGerman Sep 29 '22 at 11:52

0 Answers0