Can you help me with expression for array: ["232","2323","233"]
I try this: /^\[("\d{1,7}")|(,"\d{1,7}")\]$/
But this expression is not working properly.
I use ruby(rails).
-
2what is the expected output || what do you want to match?VladL– VladL2013-01-15 12:01:23 +00:00Commented Jan 15, 2013 at 12:01
Add a comment
|
3 Answers
You may try this ( though it may allow leading ,):
^\[(,?"\d{1,7}")*]$
5 Comments
Naveed S
Why a
, before the opening " and after the closing "?manojlds
@NaveedS - Unintentionally added. My description was right, but forgot to remove one of the
,Yam Marcovic
Note this may capture an empty array as well.
Naveed S
@YamMarcovic empty array is allowed I think. @manojlds I suggest a correction
^\[(("\d{1,7}")(,"\d{1,7}")*)?\]$ as it validates the array well. My suggestion for the edit was rejected.Yam Marcovic
@NaveedS And perhaps even more functional. :) Was just stating a fact to be aware of.