Click here to Skip to main content
15,913,361 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Regular Expression - Achievement unlocked Pin
PIEBALDconsult5-Feb-14 11:29
mvePIEBALDconsult5-Feb-14 11:29 
GeneralRe: Regular Expression - Achievement unlocked Pin
Marco Bertschi5-Feb-14 20:22
protectorMarco Bertschi5-Feb-14 20:22 
GeneralRe: Regular Expression - Achievement unlocked Pin
Jochen Arndt5-Feb-14 21:34
professionalJochen Arndt5-Feb-14 21:34 
GeneralRe: Regular Expression - Achievement unlocked Pin
Marco Bertschi5-Feb-14 21:35
protectorMarco Bertschi5-Feb-14 21:35 
GeneralRe: Regular Expression - Achievement unlocked Pin
SoMad5-Feb-14 11:12
professionalSoMad5-Feb-14 11:12 
GeneralRe: Regular Expression - Achievement unlocked Pin
Marco Bertschi5-Feb-14 20:17
protectorMarco Bertschi5-Feb-14 20:17 
GeneralRe: Regular Expression - Achievement unlocked Pin
JimmyRopes5-Feb-14 16:29
professionalJimmyRopes5-Feb-14 16:29 
GeneralRe: Regular Expression - Achievement unlocked Pin
BillWoodruff5-Feb-14 17:38
professionalBillWoodruff5-Feb-14 17:38 
Congratulations, Marco; I believe learning, and mastering, something new is one of the very best things in life !

It would be interesting to debate (perhaps on the C# forum ?) the short- and long- range cost/benefits of implementing a complex mini-parser like this using RegEx vs. "brute-force" string parsing, where "cost/benefits" would be looked at from different perspectives: say, from the perspective of a manager of programmers vs. a front-line programmer's perspective.

Of course the question of "constraints" immediately arises: what makes parsing the range of inputs you show more difficult is:

1. possible ambiguity of the "-" glyph: it is a separator for the Date component, and a sign-indicator for the time-offset.

2. possible ambiguity of the "." glyph: it is a presence/absence indicator for milliseconds, and a decimal-point for the time-offset.

If, you, the creator, have control over all possible inputs, and can ensure there will always something like ".0Z" indicating no milliseconds, and there will always be some other character than "-" separating year, month, day, then, obviously parsing becomes so much more simple.

However, maybe "control" is an academic issue here because the standard you are coding to allows such latitude in input format; I don't know anything about the RFC you are using.

As an experiment, I timed how long it took me to create a non-RegEx solution to parsing your sample data: about thirty minutes (code on request).

Since this was done early AM my time (GMT +07), and I was not fully caffeinated, perhaps I could have done this in twenty minutes, or less, later in the day, or evening.

Anyone up for debate ?
“But I don't want to go among mad people,” Alice remarked.

“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”

“How do you know I'm mad?” said Alice.

“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll

GeneralRe: Regular Expression - Achievement unlocked Pin
JimmyRopes5-Feb-14 18:14
professionalJimmyRopes5-Feb-14 18:14 
GeneralRe: Regular Expression - Achievement unlocked Pin
BillWoodruff5-Feb-14 19:46
professionalBillWoodruff5-Feb-14 19:46 
GeneralRe: Regular Expression - Achievement unlocked Pin
JimmyRopes6-Feb-14 2:12
professionalJimmyRopes6-Feb-14 2:12 
GeneralRe: Regular Expression - Achievement unlocked Pin
Marco Bertschi5-Feb-14 20:14
protectorMarco Bertschi5-Feb-14 20:14 
GeneralRe: Regular Expression - Achievement unlocked Pin
BillWoodruff5-Feb-14 21:20
professionalBillWoodruff5-Feb-14 21:20 
GeneralRe: Regular Expression - Achievement unlocked Pin
Marco Bertschi5-Feb-14 21:24
protectorMarco Bertschi5-Feb-14 21:24 
GeneralRe: Regular Expression - Achievement unlocked Pin
Steve Wellens5-Feb-14 17:51
Steve Wellens5-Feb-14 17:51 
GeneralRe: Regular Expression - Achievement unlocked Pin
Septimus Hedgehog5-Feb-14 21:29
Septimus Hedgehog5-Feb-14 21:29 
GeneralRe: Regular Expression - Achievement unlocked Pin
Rage5-Feb-14 22:12
professionalRage5-Feb-14 22:12 
GeneralRe: Regular Expression - Achievement unlocked Pin
Fabio Franco5-Feb-14 23:02
professionalFabio Franco5-Feb-14 23:02 
GeneralRe: Regular Expression - Achievement unlocked Pin
Thornik6-Feb-14 0:24
Thornik6-Feb-14 0:24 
GeneralRe: Regular Expression - Achievement unlocked Pin
svella6-Feb-14 3:17
svella6-Feb-14 3:17 
GeneralRe: Regular Expression - Achievement unlocked Pin
Marco Bertschi6-Feb-14 3:29
protectorMarco Bertschi6-Feb-14 3:29 
GeneralRe: Regular Expression - Achievement unlocked Pin
TheFigmo6-Feb-14 4:34
TheFigmo6-Feb-14 4:34 
GeneralRe: Regular Expression - Achievement unlocked Pin
Marco Bertschi6-Feb-14 4:37
protectorMarco Bertschi6-Feb-14 4:37 
GeneralRe: Regular Expression - Achievement unlocked Pin
syspau6-Feb-14 7:52
syspau6-Feb-14 7:52 
GeneralRe: Regular Expression - Achievement unlocked Pin
Ralph Little6-Feb-14 7:56
Ralph Little6-Feb-14 7:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.