Alex Mass
Alex Mass

Reputation: 191

Regex: number and comma alternation between double quotes

I need to create a regex that matches a "1,2,3,10,12312" pattern.

As I understand it would start with /([""']) to match the double quotes but I'm lost when I try to get to the \d digit and comma alternation.

what would be a valid regex to do that?

Upvotes: 0

Views: 84

Answers (1)

Jan
Jan

Reputation: 43199

You have some choices, one being:

"\d+(?:,\d+)*"

To even allow empty double quotes (""), change the expression to

"\d*(?:,\d+)*"

See a demo on regex101.com.

Upvotes: 3

Related Questions