Well, it doesn't make sense as an isolated question, but we'll assume you have a practical need.
To do what you need, you need advanced regex features that can look at the match or lack thereof and its context. For example, if your regex needs to match a "\\.[45]", which is a
Java source string
pattern for decimal followed by 4 or 5, you can use the match API to find the substring that preceded the match, the substring that comprises the matched character sequence, and the substring that follows the matched character sequence.
You can do very powerful things like match and capture values from multiple sub-patterns in your match pattern as well, but that's more than you need at the moment.