Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
ECMAScript (JavaScript)

/
[+-]?(((\d+\.\d*|\d*\.\d+|\d+)[+-])?((\d+\.\d*|\d*\.\d+|\d+)i|i(\d+\.\d*|\d*\.\d+|\d+)|i)|(\d+\.\d*|\d*\.\d+|\d+)?e\^(\([+-]?|[+-]?\()((\d+\.\d*|\d*\.\d+|\d+)i|i(\d+\.\d*|\d*\.\d+|\d+)|i)\))
/
gm

Description

it can detect complex number of both cartesian and Euler form.the real number in the real and imaginary part can be signed or unsigned.also it may or may not have floating Point.no problem.

But,in Euler from the imaginary part should be written between brackets.here are some example:- +5.6+7i,-.004+2.5i,6.-i,i,e^-(5i),.02e^(-2.3i),7e^(i)

Submitted by Adnan nabib - 3 years ago