Click to See Complete Forum and Search --> : String commands


abudabit
02-02-2005, 11:57 AM
Good day everbody,

I need help finding the set of commands that deal with strings. Such as exploding strings, needle and haystack searches, etc. It seems a lot harder to look up commands on the net for Java than it does for PHP.

Thank you very much.

abudabit
02-02-2005, 01:12 PM
Nevermind, I found the help file.

I don't understand the format of these commands though.

In the help file split(which explodes a string) is listed as:


public String[] split(String regex)


How on Earth does this work? If only the regex goes in the ( ), where does the string go?

I've tried things like:


myVariable = "Hello there bob!";
myVariable = String.split(" ");

and

myVariable = "Hello there bob!";
myVariable[] = String.split(" ");


but everything I try gives me errors.

abudabit
02-02-2005, 05:37 PM
Found it! Took a while, but I figured it out. Very confusing syntax! Never seen anything like it.

For anyone who might be in the same situation I was in:


myVariable = "Hello there bob!";
String Brodus[] = myVariable.split(" ");

Khalid Ali
02-02-2005, 06:07 PM
Its always fun to figure out a problem by yourself...:D

ray326
02-03-2005, 12:37 AM
Found it! Took a while, but I figured it out. Very confusing syntax! Never seen anything like it. It's straight OO. You're telling the String object to split itself in a way described by a reqular expression. The object replies to your "split" message with a string array object.