File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes String search! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic

String search!

Sridhar Srinivasan
Ranch Hand

Joined: Nov 07, 2003
Posts: 117
I need to get the values of the all the names in the following string.
str1="<P>fasfa     <INPUT id=1 maxLength=22 size=22 value=dfsd name=fdss oth="d"></P>
<P>rdrgfdg  <INPUT id=1 maxLength=33 size=33 value=fgdf name=fdgd oth="d"></P>
<P>dfgdfg <INPUT id=1 maxLength=33 size=33 value=dgdf name=dgf oth="d"></P>
<P>fdgdfgd     <INPUT id=1 maxLength=33 size=33 value=dfgd name=dsgdf oth="d"></P>"
All the four text boxes are in the same format and I am using the following code to get the values of "name".But I am getting 3 values and 1 value is missing.Can anybody help me to solve this?My code is as follows:
while(str1.indexOf("name=",index) !=-1)
index = str1.indexOf("name=",index);

str1 = str1.substring(index);
String nm = str1.substring(5,str1.indexOf(" "));%><%=index%><br><%

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

I don't really see how this is substantially different than the question you asked here. Even that question seems to have more to do with String matching and manipulation than JSP, so I'll be moving it.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: String search!
It's not a secret anymore!