Java and Javascript have different ways to replace strings like the feature “find and replace” that you see in text editors.

Java’s replace method is not ideal for noobs but only for people who know about regex. I am not that quite familiar with regex and if you wish to use that replace method under the String class in Java, you’d have to familiarize yourself with it in order to use it. The String class though, has lots of other useful methods that can be used to simulate how a search and replace function works. Here is a workaround method for people who only want a simple search and replace with the search and target both String. No regex knowledge needed.

The replace function contains two options. ‘i’ means the search would be case insensitive and ‘g’ means global, meaning it will search all instances of the search string within the str variable. If you do not include ‘g’ as its option, then only the first instance of the search string will be replaced.

Java and Javascript should have provided simple replace methods that greatly help newbies to these languages. The replaceString() method in Java is a good workaround for easy to use search and replace purposes in java.

Languages like Java and Javascript provide a method called indexOf() that returns an int of the first position of the string key found in a string. strpos() in PHP acts differently. If it finds the substring within the string, it returns an int value of the position of the substring. If it does not, it returns a boolean instead.

I find this stupid. It would have been easier if it still returned an int value like the usual -1 to indicate it didn’t find any substring inside the string.

To do an if statement using strpos() of PHP just like this Java code:

Do this in PHP:

Notice the 2 equal sign succeeding after the exclamation point? That line checks if the statement is false. If you wish to change it to a true condition statement, just put in 3 equal signs.

Upgrading your iTouch or iPhone’s firmware from 1.1.2 to 1.1.3 is easy, thanks to the jailbreak team’s easy upgrade installer.

Open your installer.app and make sure that it’s version 3. If it’s not, upgrade it first. Once done, go to the sources icon, tap any source item in your list and tap on the add button on the top right. Add this link, http://www.touchrepo.com/repo.xml

Go to the install icon below and tap on it. Look for the iphone packages and select 1.1.3

Exit installer.app and look for the apple icon with prison bars behind it broken. Tap on that icon and let it do the rest for you (downloading the package, decompressing and installing). Automatic reboot will take place after installation is done and your firmware version will then be 1.1.3. Make sure your wifi connection is on or else it wont download the package upgrade installer.

Note: Be patient when the installer upgrades itself. it may take awhile. And makre sure you back up all your source list as the upgrade cleans everything including your installed 3rd party apps.

Related Posts Plugin for WordPress, Blogger...