I am unsure about the language, but for C#
you can use the following:
string s1 = "1 AND 1 OR 1";
string s2 = s1.Replace("AND", ",").Replace("OR", ",");
Console.WriteLine(s2);
Which doesn’t use regular expressions.
If you want an array, you can use the following:
string s1 = "1 AND 1 OR 1";
string[] s2 = Regex.Split(s1.Replace(" ", string.Empty), "AND|OR");
In Java
you can replace using the same mechanism:
String s1 = "1 AND 1 OR 1";
String s2 = s1.replace("AND", ",").replace("OR", ",");
System.out.println(s2);
And to get an array:
String s1="1 AND 1 OR 1";
String[] s2 = s1.replace(" ", "").split("AND|OR");
4
solved Split multiple Words in a string [closed]