tags:

views:

79

answers:

4

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.

+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
thank you very much ;)
rolando
+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
+2  A: 

I've found decent reference here for years. It's pretty generic & aimed at getting you to use their tools, but it's still a good reference.

DaveE
+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