substring problem...

i just need to etract number from input user enter, how do i go on doing that? i try String st = new st.length().substring(); but always give me exception error
[181 byte] By [n_dilaha] at [2007-11-26 12:22:02]
# 1
Remove the new. The substring() method is from the String class, but the length method returns an int. What exactly are you trying to do?
CaptainMorgan08a at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 2
Please refer to the JavaDoc for how to use the substring() method. The substring() method is under String class.
khookha at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 3
int a = modified.indexOf("t"); String substr = modified.substring(modified.length(), a-6);this code is wat i manage to do but it will read from the start of the string..now i want it to read from the back is there a way to do it?
n_dilaha at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 4

> int a = modified.indexOf("t");

> String substr =

> modified.substring(modified.length(), a-6);

>

>

> this code is wat i manage to do but it will read from

> the start of the string..now i want it to read from

> the back is there a way to do it?

String substr = modified.substring(a-6);

will give you all the characters starting at index a-6 to the end of the string.

warnerjaa at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 5
What exactly are you trying to do? Can u suggest any example input?
EKTa at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 6

how do i use substring to get the last characters of a word (field). For example, the datavalue in field = abcdefg25. I need to get the final 4 chars "fg25". The field is string and could be a long string so I need to start at the end of the field and count back .

so is there a way to do this?

thankyou..

n_dilaha at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 7
> so I need to start at the end of the field and count back .So if the string was say 100 characters and you wanted the last 4, where wouldyou start?
pbrockway2a at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 8
try using this..String st ; //contains input from userString substr = st.substring(st.length() - 4));i think it will work provided u always have to fetch last 4 chars.
EKTa at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...
# 9
thank you i manage to do it
n_dilaha at 2007-7-7 15:14:40 > top of Java-index,Archived Forums,Socket Programming...