我正在尝试使用 regex
获取字符串中的短语列表,我需要这样:
- "teste"
on:
CREATE TABLE teste
or
CREATE TABLE IF NOT EXISTS teste
我正在尝试这个:
CREATE (TABLE|TABLE IF NOT EXISTS) ([a-zA-Z]+)
有什么建议吗?
谢谢!
-- 更新
我只需要得到“teste”...如果我需要在“table group”上使用括号,我如何才能得到这个表达式?
最佳答案
Balancin,你想在 java 中找到这个吗?
String regexToFind = ".*[tT][eE][sS][tT][eE].*";
String inputOk = "CREATE TABLE teste ";
String inputNotOk = "CREATE TABLE notok ";
System.out.println(inputOk.matches(regexToFind));
System.out.println(inputNotOk.matches(regexToFind));
关于java - 带短语替代的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20891170/