|
Marco Bertschi wrote: (I have tried to avoid them, but I eventually got that they are absolutely inavoidable, especially when it comes to parsing complex strings) be the coolest boy in the sandbox.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Do not feed the troll ! - Common proverb
|
|
|
|
|
Marco Bertschi wrote: And that's the string it will parse: 2014-2-5T21:36:14.315Z+1.5
You didn't need to tell us what it will parse, it's immediatelly obvious what the regex is for. Anyone can see that.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
----
Our heads are round so our thoughts can change direction - Francis Picabia
|
|
|
|
|
Nothing beautiful, looks like a dump. [0-9] is just a \d.
|
|
|
|
|
You could simplify/shorten it by replacing each instance of [0-9] with \d and getting rid of [] around single characters, though I suppose that could make it less readable.
|
|
|
|
|
|
I have managed to avoid this convoluted mess for over 30 years. And with a little luck, when i die i will STILL not speak regex.
.net string methods work just fine for me. About as fast for 90% of your needs and more readable for 100% of your needs.
The 2 or 3 times i have actually needed the power of regex in 30 years, i just sub'd out that line of code. And rather than learning/debugging/banging head .... I went to the beach swilling cheap whiskey and chasing cheaper women.
My advice to those who dont yet know regex....impress your peers with cheap whiskey and women and forget about the regex. Both make your head hurt....but one is less fun.....
|
|
|
|
|
I didn't found RegEx to be too hard, after finding out the basic principles at least. It's the same as with every new thing: Learning by doing!
Clean-up crew needed, grammar spill... - Nagy Vilmos
|
|
|
|
|
I think this site is the best tutorial/guide to regular expressions:
http://www.regular-expressions.info/tutorial.html
Clear descriptions of everything from simple to complex.
---
I like this site for testing expressions:
http://www.regexr.com/
It's an online testing tool (plus a downloadable version if you like). Paste in your expression, paste in your text, see where it matches, with analysis, hover over matches to see groups.
|
|
|
|
|
You can probably compress it a little. If you are matching a single character, then you don't need []:
[0] => 0
[:] => :
[0][1][0-2][\.]? => 01[0-2]\.?
.? I think needs to be quoted where you mean ".": . => \.?
Also, you can often use meta characters to save some finger work:
[0-9] => \d
[0-9]{4} => \d{4}
Also, some of the expressions don't need to be bracketed:
([0-9]{4}) => \d{4}
You only need the brackets if you want the parser to be able to treat it as a unit in larger ops.
Just some ideas. Nice work though!
|
|
|
|
|
One approach I have used with varying levels of utility is to treat the regex pattern like an algebraic expression. Factor out common terms and assign them to variables. Use replication counts, etc. This can simplify the final result and make it more maintainable.
Your pattern can be simplified a bit and made more readable somewhat by this. I found other strings like valid IP addresses can be greatly simplified this way.
Maybe this is useful to you!?
"Courtesy is the product of a mature, disciplined mind ... ridicule is lack of the same - DPM"
|
|
|
|
|
Has any looked at the MSDN pricing lately?
I do some MS Office (excel) integration for my customers so it requires that I get their version of MS Office (all the versions; 97 to 2013) to program against. To have access to Office I need to upgrade from the MSDN Pro to MSDN Premium... which costs $5000 more!
Can anyone explain to me how they can justify charging developers $5000 to integrate with their products? I'm not writing the president's speeches using these installs. I'm writing software so my customers will continue to use MS products and purchase licenses.
I don't understand. What am I missing... besides the money to do it?
Joel Palmer
Data Integration Engineer
|
|
|
|
|
Nope, you didn't miss anything, it's the money.
It was broke, so I fixed it.
|
|
|
|
|
Joel Palmer wrote: I don't understand. What am I missing...
It's MS missing common sense.
Clean-up crew needed, grammar spill... - Nagy Vilmos
|
|
|
|
|
Joel Palmer wrote: how they can justify charging developers $5000 It's called business.
Veni, vidi, abiit domum
|
|
|
|
|
You've missed the point. Developers are MS life blood. If I'm buying a MSDN subscription then I'm a pretty serious developer. As a developer I keep my customers coming back for more when I meet their requirements and if I do that using MS technology then the customers buy more MS licenses.
Good business would be to let developers increase the MS bottom line by having them using more MS products in their solutions. Pricing their products out of a developer's solutions does not make any business sense.
Joel Palmer
Data Integration Engineer
|
|
|
|
|
You are making a couple of faulty assumptions: that MS care about developers, and the MS care about end users. They don't: they care about money. And the large companies they expect to sell the top-end product to will just pay up and move on, because it isn't the people signing the purchase order's money. While there are people who will pay it, they will continue to gouge charge.
Have to considered buying second hand copies of office on FleaBay to complete your collection that way, probably cost less than $500 for the lot...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: You are making a couple of faulty assumptions: that MS care about developers, and the MS care about end users. Er, no, I didn't make those assumptions anywhere.
Veni, vidi, abiit domum
|
|
|
|
|
I know you didn't.
But I think Joel did...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Not true. Developers are the lifeblood of MSFT and we create the ecosystem from which they generate $billions of profit. Unfortunately, they do not understand the developer community. If they did, they would have free MSDN licenses for individual developers and charge for corporate licenses for those who develop commercial products. Developers like me generate huge revenues and profits for MSFT through SQL Server, Office, Azure, etc. licenses yet we have to pay dearly for the privilege (Visual Studio license fees, MSDN subscription, TFS, training fees and alike). It is just sad.
|
|
|
|
|
John Korondy wrote: Not true. What's not true? I think maybe this reply belongs somewhere else.
Veni, vidi, abiit domum
|
|
|
|
|
I agree with your conclusions but I don't agree that they don't care.
MS is made up of a bunch of developers and we're developers. I think that's just a brash and over-extended generalization. Unless you're saying that you don't care about the work you do and you suspect that all developers are the same way. Just like the company I work for, they are priced at "what the market will bare".
However, I do agree that its because we generally aren't the one filling the PO. Because we are one step removed they tend to get away with over-inflating their value. I'm just saying that it doesn't make business or logical sense that they'd price it with this much excess.
Yes, Fleabay is likely my next step. Got a copy of MS Office 97 for sale?
Joel Palmer
Data Integration Engineer
|
|
|
|
|
|
You must be a joy to have as a co-worker. Oh no! Its 1/100ths empty. Evidentially you've never written code in Notepad.
Joel Palmer
Data Integration Engineer
|
|
|
|
|
Just a realist when it comes to MS: I got fed up with Beta testing on DOS because they never listened to feedback even then.
Joel Palmer wrote: Evidentially you've never written code in Notepad.
I've done worse: EDLIN[^]
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: I've done worse: EDLIN[^]
And you can still go back[^]
Clean-up crew needed, grammar spill... - Nagy Vilmos
|
|
|
|