Reputation: 1486
I have a string contains multi language text as follow
{|en|}Audio Albums{|/en|}{|ar|}الألبومات الصوتية{|/ar|}
I need a function to get the text of specific language
getText("en") should returns Audio Albums
I think I have to use regular expression.
Upvotes: 0
Views: 61
Reputation: 18825
This should work:
Pattern pattern = Pattern.compile("\{\|"+lang+"\\|\\}(.*)\\{\\|/"+lang+"\|\}");
Matcher matcher = pattern.matcher(content);
return matcher.find() ? matcher.group(1) : null;
Upvotes: 1