Do Yourself a Favor: Learn Regular Expressions

The first programming language I learned was Perl. Perl was easy to do many things with and it also allowed me to manipulate text strings. Except that instead of doing it the easy way I would often write very, very convoluted chunks of code in an attempt to get the data into or out of a string that existed. I was afraid of this monster that they called RegEx, or as it is properly known: Regular Expressions. Regular Expressions allow you to write an abbreviated syntax structure that will look for matches and patterns within the text string and then, depending on the function you’re using, do a comparison (match) or do a text replacement.

Just last night I was trying to manipulate a URL and get one parameter out of it, the view parameter in JavaScript. instead of a bunch of indexOf calls and burying myself in lines of code I got the variable with one line of code:
tempStr.replace(/(^.+)(view=)([a-z_]+)(&.+)/, "$3");
JavaScript syntax allows you to use the forward slash to wrap the beginning and end of a regular experssion, then I used a group of regular expressions within that text to find the view value. Upon finding the match I printed out the third pattern that matched into a variable that is returned (patterns in this context are grouped with parenthesis).

You can learn more about regular expesesions here, but I recommend you find a tutorial for using regular expressions in the languages you code in.