1

I am new to JSTL and figuring out a way to split a string using another string. For example supppose my string is

s= "Hello! Good Morning", 

and the

t = "Good ",

then I should have str[0] = 'Hello! ' and str[1] = 'Morning'. However if I put this into

${fn:split(s, t)}

it is removing all 'G','o','d' and ' '.

Thanks

  • [look here for some understanding](https://stackoverflow.com/questions/10304084/how-to-correctly-split-strings-in-jstl) and probably use google as well – XtremeBaumer Jul 19 '17 at 09:45

1 Answers1

0

fn:split will split your string on any of the delimiter characters, so simply use the replace function fn:replace to pick up a more convenient delimiter.

<c:set var = "newString" value = "${fn:replace(s, t, '-')}"/>

Then you can use split without problems:

${fn:split(newString, '-')}
Matteo Baldi
  • 5,613
  • 10
  • 39
  • 51