Например,
Код: Выделить всё
String myString = "IF What young > old, 'Price 1', 'Prediction One', 'Mother''s Day', good";
Код: Выделить всё
String myRegex = "\\b(?!\\')[a-zA-Z_]+\\d*[.]?[a-zA-Z_]*\\d*(?!\\')\\b";
Pattern p = Pattern.compile(myRegex);
Matcher m = p.matcher(myString);
Set mySet = new HashSet();
while(m.find()){
mySet.add(m.group());
}
System.out.println("Set: " + mySet);
This gives me:
Set: [s, young, Price, old, Prediction, IF, What, good]
Код: Выделить всё
Set: [young, old, IF, What, good]
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/792 ... gle-quotes