tags:

views:

68

answers:

3

Hi, how can I write regex which is matched for any string with any size?

+3  A: 

Like this: 

.*
SLaks
Explanation: . matches any character, * means 0 or more.
Ricket
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
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.
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
By "any sized string" I think he means "every string."
Matt Ball
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
+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