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

1

1 Answer 1

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, '-')}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.