Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^([-+]?[0-9]*\.?[0-9]+[\/\+\-\*%])+([-+]?[0-9]*\.?[0-9]+)$|^[+-]?[0-9]+$
/

Description

RegEx matches: '5', '+5', '-5', '5+5', '-5+5', '+5+5', '5+9+7*-2' RegEx doesn't match: '5+', '5-', '5+9-', 'asdfasf5+5'

Submitted by David Weitzenfeld - 10 years ago