What is the best way to store and work with language dependent regular expressions in Android?

I use a bunch of language-dependent regular expressions in my project,

For example (the simplest):

\b(one|two|three|...|\d+)\b

Therefore, I want to save these regular expressions as values-en/re.xml, and then use them through Context/ R.re.*to parse the string entered by the user.

<string name="number_re">\b(one|two|three|...|\d+)\b</string>

So, if he uses Russian and introduces some phrase in Russian, I will use values-ru/re.xmlwith some meaning, for example:

<string name="number_re">\b(|||...|\d+)\b</string>

Is this a suitable way (and it won’t work on some special characters used both in string resources and in regular expressions), or is there another way to do this that I missed?

+3
1

, ( ). . , , . . , , .

+1

Source: https://habr.com/ru/post/1794920/


All Articles