Friday, 15 May 2015

c# - Regex to match string delimited with two types of delimiter -



c# - Regex to match string delimited with two types of delimiter -

i don't understand how regex expressions set together, here's question.

i have delimited string 1,3;5,1;6,4 , on. have here storing shopping cart products ids , volumes. 1,3 mean have product id "1" , quantity 3. products (with volumes) delimited ";".

what need set regex validate such string. positive numbers allowed limitation let's 1 10000.

does has solution that?

this regex pattern matches on semicolon-delimited number pairs, comma separates members of each pair, , each number between 1 , 10000:

^([1-9]\d{0,3}|10000),([1-9]\d{0,3}|10000)(;([1-9]\d{0,3}|10000),([1-9]\d{0,3}|10000))*$

there must @ to the lowest degree 1 pair. if there 1 pair, no semicolon follows it. semicolons should nowadays between neighboring pairs.

c# asp.net regex

No comments:

Post a Comment