Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(?!:\W)(\-)?(\d+)[.]?(\d+)?
/
gm

Description

const s = '23+-22.2222+-2334+5-5/22*5*-8'; const re = /(?!:\W)(\-)?(\d+)[.]?(\d+)?/gm; console.log ( s.match ( re ) ); //[ '23', '-22.2222', '-2334', '5', '-15', '22', '5', '-8' ]

Submitted by Kasap Victor - 3 years ago