Чтобы сопоставить любое число от 1,800,000
до 999,999,999
, за которым следует пробел, а затем буква K
, вы можете использовать:
\b(?:1,[89]|(?:[2-9]|[1-9]\d{1,2}),\d)\d\d,\d{3} K
Демо: https://regex101.com/r/H3qaB4/1
Разбивка:
\b # Word boundary.
(?: # Start of a non-capturing group.
1, # Matches `1,` literally.
[89] # Matches 8 or 9 literally.
| # Alternation (OR).
(?: # Start of 2nd non-capturing group.
[2-9] # Matches any digit between 2 and 9.
| # OR..
[1-9] # A digit between 1 and 9.
\d{1,2} # Followed by one or two digits.
) # End of 2nd non-capturing group.
, # Matches `,` literally.
\d # Matches one digit.
) # End of 1st non-capturing group.
\d\d # Matches two digits.
, # Matches `,` literally.
\d{3} # Matches 3 digits.
K # Matches `K` literally.
Чтобы сделать нижнюю границу 1,200,000
вместо 1,800,000
, вы можете просто заменить деталь [89]
на [2-9]
:
\b(?:1,[2-9]|(?:[2-9]|[1-9]\d{1,2}),\d)\d\d,\d{3} K
Демо: https://regex101.com/r/H3qaB4/2