两个正则表达式之间的 OR 符号
我需要提取 FROM
和 WHERE
或 ;
之间的单词
,为此我有
Pattern p = Pattern.compile("(?<=\\bFROM\\b).*?(?=\\bWHERE\\b)");
这工作正常。
示例 1:
input = "select * from emp, dept where 1 =1 "
使用上面的模式,它将返回为
emp, dept
示例 2:
input = "select * from emp, dept"
根据上面的输入,我写如下:
Pattern p = Pattern.compile("(?<=\\bFROM\\b).*?(?=\\bWHERE|;\\b)");
返回 emp,dept
,但它没有返回。
您能帮我们解决这个问题吗?
I need to extract words between FROM
and WHERE
or ;
For this I had
Pattern p = Pattern.compile("(?<=\\bFROM\\b).*?(?=\\bWHERE\\b)");
This is working fine.
Example 1:
input = "select * from emp, dept where 1 =1 "
Using above pattern it will return as
emp, dept
Example 2:
input = "select * from emp, dept"
From the above input I wrote like below:
Pattern p = Pattern.compile("(?<=\\bFROM\\b).*?(?=\\bWHERE|;\\b)");
to return emp,dept
, but it's not returning that.
Will you please help us to resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修改表达式以识别 WHERE 子句中的所有字符,并将其设为可选
Modify your expression to recognize all the characters in the WHERE clause, and make it optional