我希望在Java中找到一个正则表达式,适用于Windows Server 2008操作系统版本且不包含"R2"。目前我正在使用的正则表达式为 -
(?i)Win\w*\s*(?i)Server\s*(2008)\s*(?!R2)\s*\w*
可能的取值:
Windows Server 2008 数据中心版
- 匹配正确Windows Server 2008
- 匹配正确Windows Server 2008 R2 数据中心版
- 不匹配Windows Server 2008 r2 数据中心版
- 不匹配Windows Server 2008 R2
- 匹配不正确(因为正则表达式中的\w*
包括了R2
)
\s*
。你是在使用String matches()
的上下文中吗? - Sebastian Proske