Yamaha32088
Yamaha32088

Reputation: 4163

Match commas with no white space before or after excluding thousands separators

I am trying to match a comma surrounded by alpha characters with no space leading or trailing but to ignore if they are surrounded by numerals such as the thousands separator in a large number.

Below is what I have so far but the problem is that the Full Match returns the comma with the first character. ,v in this example. However I just need the comma to be returned as the full match. I have tried (,)(?:[^\d\s]) and also (,)(?:[^\d\s])\K but with the \K the full match is empty.

I want to match the first and third line from this example but ignore the second and fourth:

uncased,vertical
80,000 btu
80,000,vertical
80,000, vertical

https://regex101.com/r/YH0Vd0/1

Upvotes: 0

Views: 126

Answers (1)

m87
m87

Reputation: 4523

The following regex ( using positive look-ahead ) should do it :

,(?=[^\d\s])

DEMO

Upvotes: 1

Related Questions