Tuesday, 11 April 2017

Split string and get array using regExp in javascript/node js

I am writing js code to get array of elements after splitting using regular expression.

 var data = "ABCXYZ88";
 var regexp = "([A-Z]{3})([A-Z]{3}d{2})";
 console.log(data.split(regexp));

It returns [ 'ABCXYZ88' ]

But I am expecting something like ['ABC','XYZ','88']

Any thoughts?



via Dinesh

No comments:

Post a Comment