I'm trying to get some information as groups out of some text using regex.
Desired result is out of the text: Please check the Health of the JVM=acq855SW1-srv1 Please check the acq855SW1-srv2 profile.It seems like down
to get
My regex so far is (?<Description>.*?the (?:JVM=|)(?<JvmName>[^\s]+)(?: profile.*+|))
and I'm trying to avoid the fact that it`s taking also the "Please check the Health" as a match.
How can I make in a way that it wont stop at "the Health" ?
An easy fix is to differentiate Health
from the others adding the constraint that that value must contain a -
.
This can be done changing [^\s]+
to [^\s]+-[^\s]+
.
So the result regex is:
(?<Description>.*?the (?:JVM=)?(?<JvmName>[^\s]+-[^\s]+)(?: profile.*+|))
If the -
is an assumption that cannot be done, you could do the same with numbers.
[^\s]+\d[^\s]+