【发布时间】:2015-02-27 03:15:33
【问题描述】:
对于字符串 x 我想匹配单词 abc 之间 https:// .... abc .../../..
- 确定它是否感兴趣
例子
2) 如果字符串是 https:// .... xyz .../abc/mnk --> 字符串不感兴趣
3) 或字符串为 https:// .... xyz .../mnk/abc --> 字符串不感兴趣
用于正斜杠匹配
Regex to match both slash in JAVA
http://bug-bounty.blogspot.com/2013/01/java-regex-forward-slash.html
为了匹配正斜杠,我在 partern 下面尝试了 \ 并且我尝试了
a) x.matches("https://(.*)oem(.*)/(.*)"
b) x.matches("https:\\/\\/(.*)oem(.*)\\/(.*)"
c) x.matches("https://(.*)oem(.*)\/(.*)" --> errors
d) x.matches("https://(.*)oem(.*)/(.*)/(.*)") --> works
即使认为 d) 工作 a) 和 b) 都失败了条件二 - 这意味着我没有正确理解事情。我错过了什么?
【问题讨论】: