Putting a space in the range quantifier in the regular expression seems syntactically valid:
/.{1, 2}/ # => /.{1, 2}/
However, such a space apparently changes behavior compared to the absence of such a space:
"a" =~ /.{1,2}/ # => 0 "a" =~ /.{1, 2}/ # => nil
What would be the meaning of a regular expression with space in a range such as /.{1, 2}/ ?
/.{1, 2}/
matches "a{1, 2}" . Although this is syntactically valid, {1, 2} ceases to be a bounding quantifier.
"a{1, 2}"
{1, 2}
As soon as a space appears between the comma and the numeric value max , {1, 2} behaves like a literal string match.
space
max
literal