-2

I tried regex 'minus', 'plus', 'multiplication' and 'division', /[*+-/]/. This regex matches all the operator signs, but it also matches decimal point. How come? How to match only these operators but not decimal?

I did it on https://www.regexpal.com/

Ozubergs
  • 145
  • 1
  • 2
  • 9

1 Answers1

-1

Inside square brackets, the construction a-b matches any character sorting between a and b. The regular expression [*+-/] matches any one of the following:

  • * as asterisk, U+002A.

  • Any character sorting between + (U+002B) and /, namely + (plus sign, U+2B), , (comma, U+002C), - (hyphen-minus, U+002D), . (period, U+002E) and / (solidus, U+002F).

AlexP
  • 4,370
  • 15
  • 15