private static Regex Regex(bool lws, bool rws)
{
return new Regex(
"^"
+ (lws ? @"\s*" : null)
/*
number = [ minus ] int [ frac ] [ exp ]
decimal-point = %x2E ; .
digit1-9 = %x31-39 ; 1-9
e = %x65 / %x45 ; e E
exp = e [ minus / plus ] 1*DIGIT
frac = decimal-point 1*DIGIT
int = zero / ( digit1-9 *DIGIT )
minus = %x2D ; -
plus = %x2B ; +
zero = %x30 ; 0
*/
+ @" -? # [ minus ]
# int
( 0 # zero
| [1-9][0-9]* ) # / ( digit1-9 *DIGIT )
# [ frac ]
( \. # decimal-point
[0-9]+ )? # 1*DIGIT
# [ exp ]
( [eE] # e
[+-]? # [ minus / plus ]
[0-9]+ )? # 1*DIGIT
" // NOTE! DO NOT move the closing quote
// Moving it to the line above change the pattern!
+ (rws ? @"\s*" : null)
+ "$",
RegexOptions.IgnorePatternWhitespace
| RegexOptions.ExplicitCapture
| RegexOptions.Compiled);
}