extraction of text in jsp
hello, i was wandering hw cld you extract text from the below string...
using a form i recieve a string as a parameter the format as:
"some text , some text, some text "
i want to extract the text after the second comma...
i can get the first two text bu using split at the the comma but how do
i get the third?
thanks,
moh
# 1
String inputStr = "some text , some text, some text ";String[ ] splitStr = inputStr.split(",");out.println(splitStr[2]);
# 6
well, what is the seperator in the text. For string tokenizer or anything a seperator is required like comma(,).hash(#),pipe(|) like this. If the string doesn't contain any such thing then you need to seperate the string as per your requirement first and then use string tokenizer.
String s="you|are|so|good|like|this";
string is se
StringTokenizer st = new StringTokenizer(s,"|");
While st.hasMoreTokens()
{
System.out.println(st.nextToken());
}
good luck.