Is there any library API or regex pattern to split a String on some delimiter and automatically trim leading and trailing spaces from every element without having to loop the el
Edited to correct whitespace error that was pointed out by Marcus.
I think that the proper regex should be [\s]*#[\s]*:
str.split("[\\s]*#[\\s]*");
Tested on : http://regexpal.com/