Regular Expression Help!
-
Can someone please give me a regular expression that I can use with the split() method to delimit the a string such as the one that follows into 20 separate fields. It is comma-quote delimited, however nulls are not quoted (,,) and it is possible to have commas inside a quoted value ("1,2,7,7,8-PECDD"). Thanks...David "42679","A106037#2","-9999","BL0414WJ","BL0414WJLB1","Laboratory Blank","DIOXINS/FURANS (GHK)","04/14/2000","04/19/2000","pg/l","1,2,7,7,8-PECDD","40321-76-4","6.016","6.016","U",,,"NO","YES" David
-
Can someone please give me a regular expression that I can use with the split() method to delimit the a string such as the one that follows into 20 separate fields. It is comma-quote delimited, however nulls are not quoted (,,) and it is possible to have commas inside a quoted value ("1,2,7,7,8-PECDD"). Thanks...David "42679","A106037#2","-9999","BL0414WJ","BL0414WJLB1","Laboratory Blank","DIOXINS/FURANS (GHK)","04/14/2000","04/19/2000","pg/l","1,2,7,7,8-PECDD","40321-76-4","6.016","6.016","U",,,"NO","YES" David
,?"(?<value>.*?)"|,?(?<value>.*?) This will let you extract the values as named groups, but will not work as a split separator. I see dumb people
-
,?"(?<value>.*?)"|,?(?<value>.*?) This will let you extract the values as named groups, but will not work as a split separator. I see dumb people
Daniel Turini wrote: ,?"(?.*?)"|,?(?.*?) I have just added CodeProject support to your regexp : ,?"(?.*?)"|,?(? :confused: .*?)
-
Daniel Turini wrote: ,?"(?.*?)"|,?(?.*?) I have just added CodeProject support to your regexp : ,?"(?.*?)"|,?(? :confused: .*?)
Oh, I just love regex, it's an art form. Here's a regex which can validate (it's not mine, I found it on the web): 1. All valid dates from 1/1/0001 to 31/12/9999 2. Correctly validates leap years 3. It's valid for the regex classes on .NET framework ^(?: (?: (?:0?[13578]|1[02])(\/|-)31)|(?: (?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?: (?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?: (?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$ Remove all the spaces from it, I've added some to bypass the emoticons. I see dumb people
-
Oh, I just love regex, it's an art form. Here's a regex which can validate (it's not mine, I found it on the web): 1. All valid dates from 1/1/0001 to 31/12/9999 2. Correctly validates leap years 3. It's valid for the regex classes on .NET framework ^(?: (?: (?:0?[13578]|1[02])(\/|-)31)|(?: (?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?: (?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?: (?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$ Remove all the spaces from it, I've added some to bypass the emoticons. I see dumb people
Who needs MSIL obfuscation when you've got RegExp. Of course, the trouble is you obfuscate your code to yourself :laugh: