Denniz Denniz - 7 months ago 33
C# Question

Two regex matches with space between the matches

I'm trying to match a string with this regex:

The regex:

[ ](\d{4}|\d{4}[A-Za-z]{3})[ ]

NOTE: there might be 3 characters after the numbers, that's why [A-Za-z]{3} is in there.

This is the string I wan't to match in:

281320Z 26015KT 9999 3333 FEW028 SCT033 BKN053 16/10 Q1007=

So in this case it will only select 9999
since there's a space that match1 will reserve.
In this case:

281320Z 26015KT 9999 3333 4444 FEW028 SCT033 BKN053 16/10 Q1007=

9999 and 4444 will be selected.

How can i do so 9999, 3333, 4444 get selected?


You could use a regex like this:


Working demo