[android-beginners] Re: how to read specific part in a string

2009-03-17 Thread guruk
I will try it... looks good :) i love this regex stuff, but still have no clue about.. haha but if it works.. respect.. can you also do something like sm1 (serge) that includes also attributes like: status code=0/ So i guess we need something like. takeit (OrgString, Tagstring, AltTag) like:

[android-beginners] Re: how to read specific part in a string

2009-03-17 Thread Ralf
I'd suggest to take that opportunity to learn on regexp and try a/ to understand what the one we gave you does and b/ how to modify it with your new requirement. Franky, regex are not that hard to come up with -- it is harder to read an existing one than to write one :-) I suggest the following

[android-beginners] Re: how to read specific part in a string

2009-03-17 Thread guruk
hi ralf, thanks for your answer. but also... your demo did not worked for me. You may try it yourself. thanks also for the links, will have a look. here now for all fellows, two routines that work - with regular tags.. if they have innertags or not - and a routine that looks specialy for

[android-beginners] Re: how to read specific part in a string

2009-03-15 Thread sm1
Looks good guruk. It's quite fast. I timed it. fyi: The code I posted earlier can also work with input of xml tags with attributes, such as Hello, this is a test start attr1=\value1\12345/start ... which is common with tags, and it also avoids raising the nasty RuntimeException

[android-beginners] Re: how to read specific part in a string

2009-03-15 Thread guruk
thanks serge, great communication. right now its ok for me, because the code who does create the tags is also from me :) so i can be sure there is always a start and ending tag. just for anyone who is interested here an extended version that does allow to search for several tags in a long

[android-beginners] Re: how to read specific part in a string

2009-03-15 Thread Ralf
Or the equivalent: public String takeit(String input, String tag) { Pattern p = Pattern.compile(.*?( + tag + )([^]*)/\\1); Matcher m = p.matcher(input); return m.matches() ? m.group(2) : null; } R/ On Thu, Mar 12, 2009 at 1:34 PM, EECOLOR eeco...@gmail.com wrote: I think that

[android-beginners] Re: how to read specific part in a string

2009-03-14 Thread Albert Hernández
I think that the methods proposed here are very heavy: XML Parsing is too much for that easy task Check it manually is not optimal I suggest you to have a look on the class StringTokenizer: http://developer.android.com/reference/java/util/StringTokenizer.html Albert On Mar 13, 11:57 pm, sm1

[android-beginners] Re: how to read specific part in a string

2009-03-14 Thread guruk
Hi and thanks for all your great help So I also like to share what I use now public String TakeIt (String xtag, String xhtml) { String x1tag = + xtag + ; String x2tag = / + xtag + ; int xstart = xhtml.indexOf(x1tag); int

[android-beginners] Re: how to read specific part in a string

2009-03-14 Thread sm1
Albert, I don't think that it can be done using StringTokenizer. serge On Mar 14, 12:17 pm, Albert Hernández albert.hernan...@gmail.com wrote: I think that the methods proposed here are very heavy: XML Parsing is too much for that easy task Check it manually is not optimal I suggest you to

[android-beginners] Re: how to read specific part in a string

2009-03-13 Thread Pankaj Bisaria
I think you need to use parse for that. 2009/3/12 guruk ilovesi...@gmail.com Hi, i have a long String and need to capture some text in between of some tags. for example: myString=Hello, this is a test start12345/start and here i like to say markioioidddad/marki what is that

[android-beginners] Re: how to read specific part in a string

2009-03-13 Thread EECOLOR
I think that would be something like this: public String takeit(String str, String tag) { return str.replace(.*? + tag + (.*?)/ + tag + .*, $1); } Greetz Erik On Thu, Mar 12, 2009 at 7:14 PM, guruk ilovesi...@gmail.com wrote: Hi, i have a long String and need to capture some text in

[android-beginners] Re: how to read specific part in a string

2009-03-13 Thread sm1
I do it this way (it works for me): /** * @param tag The tag without the angle bracket, i.e., * the given value does not start with lt;. * @param str The string containing the tags and data. * @return empty string when tag absent or str invalid. */ String