Hi, how can I write regex which is matched for any string with any size?
Explanation: . matches any character, * means 0 or more.
Ricket
2010-04-12 15:03:24
Except, the dot does not match newline characters. See this explanation: http://www.regular-expressions.info/dot.html (this was news to me, thanks to TLiebe's answer for pointing it out!)
Ricket
2010-04-12 15:09:16
As a caveat it will not match newlines in all implementations (e.g RegexOptions.SingleLine must be set in .net to match \n)
Alex K.
2010-04-12 15:10:35
A:
You wouldn't use regex to decide if something is an "any sized string".
You need to clarify on what you are looking for. What do you mean by a "string"?
NebuSoft
2010-04-12 15:00:20
Right. Thus, what's the point? He could replace his logic with if (true) depending on the language (as long as it isn't null/nil depending again on his language). Depending on the language, a check on the size would be faster than running it to the Regex engine even though it's a simple check.
NebuSoft
2010-04-12 15:08:33
+1
A:
.* will match any character except a newline any amount of times (including zero). Use .+ to match any character one or more times.
TLiebe
2010-04-12 15:01:33