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
  • 88,009
  • 5
  • 94
  • 125
careful
  • 69
  • 8

1 Answers1

0

You can use this pattern...

 s = "p=YSp%hZ5=YunnYDUuGxVxAeLCZuVvSfoutO8=";
array = s.split(/(?<=\=)/);
console.log(array);
Pushprajsinh Chudasama
  • 7,772
  • 4
  • 20
  • 43