Regarding usage of split function

HI All,I have a problem using the split function.Consider -A(s)(age)I would like to retain only A(s), how can I do it using the split function?or some other way?Please help.Regards,Shef
[241 byte] By [shefa] at [2007-11-27 1:12:01]
# 1
Regular expressions :!Look for more info on pattern & matcher classes, those make you use regular expressions
radicjesa at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 2
I am not familiar to regex stuff...can you suggest something quickly!
shefa at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 3
> ...can you suggest> something quickly!Excuse me? Either learn regex/Java, or pay someone to do it quickly for you.
prometheuzza at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 4

If you can not or do not want to answer the questions, dont interrupt. I dont need any advice for hiring someone to solve my problem.

This forum is for helping other people who are naive to the language or are stuck or not brilliant/expert like other people in this domain, so please refrain from writing such answers.

Thanks.

shefa at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 5
If you are in a hurry and do not have time to learn basic regex, why don't you use the String's substring method ?
karma-9a at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 6

> If you can not or do not want to answer the

> questions, dont interrupt. I dont need any advice for

> hiring someone to solve my problem.

>

> This forum is for helping other people who are naive

> to the language or are stuck or not brilliant/expert

> like other people in this domain, so please refrain

> from writing such answers.

>

> Thanks.

You are being rude to ask for a quick response to people who post answers on a voluntary basis. If you want such kind of service, pay for it!

And I will post whatever I like in your thread, just as much as you can post your demands here.

prometheuzza at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 7
> Consider -> A(s)(age)> > I would like to retain only A(s), how can I do it> using the split function?String s = "A(s)(age)";s =
prometheuzza at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 8

> I would like to retain only A(s), how can I do it using the split function?

> or some other way?

You didn't describe the criteria for retaining A(s). How could one help you then?String input = "A(s)(age)";

String result1 = "A(s)";

String result2 = input.substring(0, 4);

String result3 = input.replaceAll("\\([^s]+\\)", "");

String result4 = input.split("\\(age\\)")[0];

...

TimTheEnchantora at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 9

> > I would like to retain only A(s), how can I do it

> using the split function?

> > or some other way?

>

> You didn't describe the criteria for retaining

> A(s). How could one help you then?String

> input = "A(s)(age)";

>

> String result1 = "A(s)";

> String result2 = input.substring(0, 4);

> String result3 = input.replaceAll("\\([^s]+\\)",

> "");

> String result4 = input.split("\\(age\\)")[0];

> ...

Thanks for the suggestions.

By the way A(s)(age) is just an example, I just meant that there can be more than 1 bracket and any value in them, and then I would like to keep the first bracket and discard everything after that.

Thanks anyways.

Regards,

Shef

shefa at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 10

> By the way A(s)(age) is just an example

And you know my suggestions are just nonsense, don't you?

> I just meant that there can be more than 1 bracket and any value in

> them, and then I would like to keep the first bracket and discard

> everything after that.

You mean you need to extract the starting substring up to and including the first sequence that lays between parenthesis ? I would then suggest:input.substring(0, input.indexOf(')', input.indexOf('(')) + 1)

TimTheEnchantora at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 11
im sorry but um, what is a split function?
ichbinsterbena at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 12
> im sorry but um, what is a split function? http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#split(java.lang.String)
prometheuzza at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...
# 13
thanx
ichbinsterbena at 2007-7-11 23:47:21 > top of Java-index,Java Essentials,Java Programming...