How to split a String and keep the delimiter '='

careful :

I have a string like this

String s = "p=YSp%hZ5=YunnYDUuGxVxAeLCZuVvSfoutO8=";
String[] array = s.split("=");

This array will give me an an output like this: p, YSp%hZ5, YunnYDUuGxVxAeLCZuVvSfoutO8

Desired would be to have those elements but keep the = sign like: p=, YSp%hZ5=, YunnYDUuGxVxAeLCZuVvSfoutO8=

I need to split it by = sing and keep the '=' sign somehow. Does anyone knows some pattern which will help me with it.

Foram Trada :

You can use this pattern...

 s = "p=YSp%hZ5=YunnYDUuGxVxAeLCZuVvSfoutO8=";
array = s.split(/(?<=\=)/);
console.log(array);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=357288&siteId=1