|
F*** off! Tell me it ain't so, Bernard.
Seriously, I have the same problem. There are few string.Format calls and 98% is concatenation. The context of the strings is the problem. I mean, there are sql statements containing strings like " and " and elsewhere there are messages boxes with " and ". There was one bastard of a string set to "Enter the " + something else and further on was something like reply.StartsWith("Enter the credit"). What a***hole would produce such awful stuff? And no, it wasn't me.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
"Nice" to hear that those problems are so common.
Apart from SQL statements, we excluded the log messages from localization - they' be more than the "normal" texts. That meant quite some extra work. That's a point to consider - or do you want to analyse log files in e.g. Hungarian?
|
|
|
|
|
Bernhard Hiller wrote: or do you want to analyse log files in e.g. Hungarian?
We're starting with Italian and trying to restrict the text to what the users would expect or want to see. It's tricky trying to identify the context of a string so if later end up writing Simplified Chinese to a log file then so be it. I don't think our users would want to see a message box containing an sql statement. Oh wait (slapping forehead) they already do get some of those.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
Programming is one industry where everyone is constantly attempting to specialize in generalizing!!!!
|
|
|
|
|
BTW: Get a copy of Expresso [^] - it's free, and it examines, explains and generates Regular expressions. I wish I'd written it!
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)
|
|
|
|
|
OG, thanks for the heads-up on the app. I already use RegexBuilder and RegexBuddy but you can't have too many regex tools in your toolbox. They bring different toys to the party and they're all helpful. I will download Expresso post-haste.
Update: Downloaded and quickly tried it out and the design mode tab looks very promising indeed.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
OG, as a follow up I spent a bit of time this evening using Expresso and I'm very impressed. Another tool I also use is RegexBuilder[^] (by Matt Jacobsen and Markus Renschler). While it's not a regex designer like Expresso it is an excellent parser-cum-tester.
You paste in or edit a regex string and you can create from 2 - 15 text lines. For example, I might create multiple lines showing variations of input text to be inspected. The moment you change the text or the regex you get an immediate colour change of the success or failure of the validation status on a particular line of sample text. That's useful if you are interested in specific strings. It's free which is nice.
I have a paid-for utility as well. So the three complement each other. For designing expressions, Expresso will be my striker, RegexBuddy my midfielder and RegexBuilder in defence.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
|
I want Regular Expression or any other validation for textbox to allow combination of character with digits only.. which can not be allow only digits or only character.
|
|
|
|
|
|
U can use
^[a-zA-Z0-9]+ (\\d+ | [a-zA-Z]+)
|
|
|
|
|
This is not a good regex task - it isn't strictly pattern matching, it's a counting job, which regex is pretty bad at.
While you can do it it would be horribly complex, and if you decided at a later date that you wanted to include special characters in there it would be a real PITA to maintain.
Instead, do it in code: Use two regexes - one to return all the digits, and one to return all the alpha characters. You then check that the length of both is greater than zero.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Assuming you're using the .NET RegEx class, you can use a zero-width positive lookahead assertion[^]:
^(?=.*?\d)(?=.*?\D)\w{2,}$
This means:
- You're matching the entire string -
^ and $ - The string must consist of at least two alpha-numeric characters -
\w{2,} - The string must contain any number of characters followed by a digit -
(?=.*?\d) - The string must contain any number of characters followed by a character that is not a digit -
(?=.*?\D)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
please, tell me this has a bug:
"^(((0[1-9]|[12]\\d|3[01])\\/(0[13578]|1[02])\\/((19|[2-9]\\d)\\d{2}))|((0[1-9]|[12]\\d|30)\\/(0[13456789]|1[012])\\/((19|[2-9]\\d)\\d{2}))|((0[1-9]|1\\d|2[0-8])\\/02\\/((19|[2-9]\\d)\\d{2}))|(29\\/02\\/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$"
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
That's a very long expression.
This is a shorter expression that validate dates:
^\d{4}[- /.](0?[1-9]|1[0-2])[- /.](0?[1-9]|[12][1-9]|3[01])$
Expresso[^] is a good tool to create regular expressions.
In some cases, my signature will be longer than my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|
|
thanks for the reply, we actually found a bug on that expression when entering 01/01/2013 (dd/MM/yyyy), for some reason, this value was rejected...
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: thanks for the reply
You're welcome!
Sentenryu wrote: dd/MM/yyyy
My expression is for yyyy/MM/dd. An expression for dd/MM/yyyy:
^(0?[1-9]|[12][1-9]|3[01])[- /.](0?[1-9]|1[0-2])[- /.]\d{4}$
In some cases, my signature will be longer than my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|
|
Its much shorter yes, but it's overly simplistic.
It says 31st Feb is a valid date
|
|
|
|
|
There's a difference between a valid date and a valid date format. A regex is good for checking formats, but I don't think it works for checking whether a day exists.
In some cases, my signature will be longer than my message...
<em style="color:red"> <b>ProgramFOX</b></em> ProgramFOX
|
|
|
|
|
Maybe it checks if you have to go to work too. AFAIK 1.1 is work-free.
Greetings - Jacek
|
|
|
|
|
Hi there,
I've just read the great "30 Minute Regex Tutorial", by Jim Hollenhorst. A brilliant piece of writing. Congratulations, Jim. Expresso is also a really superb tool.
I would need to go deeper into the advanced aspects of regexp, such as the examples in Table 6 (Table 6. Everything we left out.) in that tutorial.
I would like to hear some suggestions about what way I can go. Thanks a lot!
Cheers, Manuel
|
|
|
|
|
msoutopico wrote: Expresso is also a really superb tool. Yes, indeed it is.
The best suggestion I have is to find (or invent) some interesting problems, then play with Expresso to solve them (in as many ways as you can think of).
Having said that, remember that regex is not the universal solution for string processing. There are many cases where regex is not the appropriate tool.
(Remember the old saw "When all you have is a hammer, everything looks like a nail." Don't let regex become your hammer.)
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thanks Peter.
Any suggestions for regexp advanced exercises?
Peter_in_2780 wrote: There are many cases where regex is not the appropriate tool. For example?
I would depend on the case, I suppose.
Cheers, Manuel
|
|
|
|
|
sir
i am doing a project, i want to match a string with regex which will match the whole string and it dosent allow two white spaces concerrently on after the other and also it dosent allow white spaces at starting and ending of string, any number of white spaces is allowable but not concurrently one after the other
|
|
|
|
|
I'm not going to write it out for you, but how about
[beginning of string][whitespace] OR [whitespace](two or more) OR [whitespace][end of string] Any match and it's bad.
Or, depending on how you want to use it, you can invert the test.
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
i didint get what you have told
|
|
|
|