I want to find a regex in Java for a Windows Server 2008 OS version which does not contain "R2" Regex I am currently using -
(?i)Win\w*\s*(?i)Server\s*(2008)\s*(?!R2)\s*\w*
Possible values:
Windows Server 2008 datacenter- Matches correctlyWindows Server 2008- Matches correctlyWindows Server 2008 R2 Datacenter- Does not matchWindows Server 2008 r2 datacenter- Does not matchWindows Server 2008 R2- Matches incorrectly (becauseR2fits into\w*in the regex)
What am I doing wrong in the regex?
\s*after your lookahead. Are you using this in context ofString matches()?