Does anyone no of any tutorials about string parsing. I couldn't find any good ones.

God bless.
:cool:

I would just use StringTokenizer. You could easily find a good tutorial on that and it's better than using indexOf and simple math to try and parse everything.

Tell me what you're situation is first. There are some things better than others, but it all depends on what you're doing.

If you're just talking general stuff here, then you must first know that Strings are immutable. That means there's really no way to modify the original string.

If you wanted to insert a character at the beginning:

String original = "string";
String modified = "a" + original;

of course you can just modify the 'original' variable, but it's the same thing as the 'modified' variable because Strings are immutable. I would personally recommend using two variables instead of reassigning and making that one object lost in space.

>If you're just talking general stuff here, then you must first know that Strings are immutable. That means there's really no way to modify the original string.

Holy smokes! I just assumed the "java string" would be the same as the std::string (c++).

>Tell me what you're situation is first. There are some things better than others, but it all depends on what you're doing.

It's easter so we get a break from school. I was just doing a little project to keep myself entertained along with the rest of my assignments. :-).

Anyway what I need to do is take a string and manipulate it. Like I have...

string = " jfkdsliejsl*jfkeols";

And it goes through and finds a '*' then inserts "another_string";

Or erases part of the string at the position I tell it. ThanQ.

It sounds to me that Java Regular Expresions would do what you're looking to do.

Use the replaceAll(String regex, String replacement) or replaceFirst(String regex, String replacement) methods on String.

This article has been dead for over six months. Start a new discussion instead.