As you can read in the tittle i need a regular expression for getting any letter, symbol, number from 1 to 100 maxlength (any text posible). Can someone provide that for me and maybe a good link to understand how it works. Thank you.
views:
79answers:
4
+3
A:
To match any text possible of maxlength 100 you can use:
.{1,100}
to even match newlines you can use:
[\d\D]{1,100}
Notes:
.
: A metachar that matches anything but a newline.{1,100}
: min of 1 and max of 100 of the previous pattern[]
: the char class\d
: any digit\D
: any non-digit[\d\D]
: any char
codaddict
2010-03-22 16:01:24
thank you very much ;)
rolando
2010-03-22 16:24:20
+1
A:
You should be able to piece it together from here:
http://www.c-sharpcorner.com/UploadFile/prasad_1/RegExpPSD12062005021717AM/RegExpPSD.aspx
here's the MSDN start page for regex:
http://msdn.microsoft.com/en-us/library/30wbz966%28VS.71%29.aspx
David
2010-03-22 16:02:09
+1
A:
If I understand you correctly you don't really need a regular expression to do this.
var test = "test";
var result = test.Substring(0, test.Length<100 ? test.Length : 100);
Jonas Elfström
2010-03-22 16:19:08