tags:

views:

44

answers:

1

Recently I came across a character range that was the following:

[/-+]

My very simple question is, is this even a valid character range? If so, what range of characters would it match?

+2  A: 

It's not a correct range.. it would have to be [+-/] since + comes before / in the ASCII table.

Speaking of the ASCII table, the [+-/] would match +, ,, -, ., or /

Here's some test cases (JavaScript):

var r = /[+-\/]/;
r.test('foo'); // false
r.test('foo+'); // true
r.test('foo/'); // true
r.test('foo.'); // true
r.test('foo,'); // true
r.test('foo-'); // true
Matt
this is perfect. Thanks.
Alex