1

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.

Casimir et Hippolyte
  • 85,718
  • 5
  • 90
  • 121
careful
  • 59
  • 8

1 Answers1

0

You can use this pattern...

 s = "p=YSp%hZ5=YunnYDUuGxVxAeLCZuVvSfoutO8=";
array = s.split(/(?<=\=)/);
console.log(array);
Bhavik Kalariya
  • 1,231
  • 3
  • 18
Foram Trada
  • 867
  • 3
  • 14