I've got the following text:
instance=hostname1, topic="AB_CD_EF_12345_ZY_XW_001_000001"
instance=hostname2, topic="AB_CD_EF_1345_ZY_XW_001_00001"
instance=hostname1, topic="AB_CD_EF_1235_ZY_XW_001_000001"
instance=hostname2, topic="AB_CD_EF_GH_4567_ZY_XW_01_000001"
instance=hostname1, topic="AB_CD_EF_35678_ZY_XW_001_00001"
instance=hostname2, topic="AB_CD_EF_56789_ZY_XW_001_000001"
I would like to capture numbers from the sample above. I've tried to do so with the regular expressions below and they work well as separate queries:
Regex: *.topic="AB_CD_EF_([^_]+).*
Matches: 12345 1345 1235
Regex: *.topic="AB_CD_EF_GH_([^_]+).*
Matches: 4567 35678 56789
But I need a regex which can give me all numbers, ie:
12345 1345 1235 4567 35678 56789
"_EF_" / "_GH"and_ZY? That could be done by/.*(?:_EF_|_GH_)(\d+)_ZY.*/(?<=EF_)(\d+)(?=_ZY), Demo: regex101.com/r/vbLN9L/6