Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Useful String Manipulation

Strings are a wonderful thing in programming. Any character that you can read on screen is considered a string.

Tutorial Details:

PHP Tutorial

In fact, this very text your reading right now can be considered a string. Forming complex strings is a tricky business, especially when you want to format multiple strings in a specific way.

Fortunately for us, PHP includes a huge library of string manipulation functions though huge as it is, it is still not enough when we want to format complex strings like mentioned before. Using a few tricks, we can however create several wrapper functions that we can use for our benefit.

Before reading this tutorial, make sure you have a proper understanding of PHP, strings in general, and a little understanding of regular expressions.

One of the most common ideas behind web development today is that the surfer browsing your web site is in charge. They can register via HTML forms, vote in polls, or even in the concept of some web sites, create new content to be posted online almost instantly.

The problem behind these ideas is basically you have no control over what kind of data the user enters in each of the HTML forms described above. There are other tutorials to explain how to validate the data to make sure it follows a specific pattern; this is outside the scope of this tutorial. Rather here we talk about formatting the string, removing or shifting specific characters from it.

We all know, as programmers, strings are made up of just more than the characters we see. We are all familiar with the famous \n , \t, and \r characters. These nifty characters stand for line break, tab , and carriage return, respectively. What do they mean however?

Each one of these characters make up one byte and they are used to format the string we are dealing with. A string that spans 4 lines for example will most likely contain 4 line break characters. The human eye does not see them though, only they machine does. In fact when the machine encounters a line break character it does not print it on screen, but rather prints any other characters following it on a new line.


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Useful String Manipulation

View Tutorial:
Useful String Manipulation

Related Tutorials:

Build servlet-based enterprise Web applications - JavaWorld - December 1998
Build servlet-based enterprise Web applications - JavaWorld - December 1998
 
StringBuffer versus String - JavaWorld March 2000
StringBuffer versus String - JavaWorld March 2000
 
Easy Java/XML integration with JDOM, Part 2 - JavaWorld July 2000
Easy Java/XML integration with JDOM, Part 2 - JavaWorld July 2000
 
Leverage legacy systems with a blend of XML, XSL, and Java - JavaWorld October 2000
Leverage legacy systems with a blend of XML, XSL, and Java - JavaWorld October 2000
 
An open alternative to JSP - The faults of JSP So what's wrong with JSP?
How the template-based, open source API FreeMarker trumps JSP
 
Plant your data in a ternary search tree - JavaWorld February 2001
Plant your data in a ternary search tree - JavaWorld February 2001
 
Device programming with MIDP, Part 2 - JavaWorld March 2001
Device programming with MIDP, Part 2 - JavaWorld March 2001
 
Device programming with MIDP, Part 3 - JavaWorld July 2001
Device programming with MIDP, Part 3 - JavaWorld July 2001
 
XSLT blooms with Java
XSLT blooms with Java
 
Reinvented wheel
Reinvented wheel
 
Create your own type 3 JDBC driver, Part 3
Create your own type 3 JDBC driver, Part 3
 
Navigate through virtual worlds using Java 3D
Navigate through virtual worlds using Java 3D
 
Once again, only introduction
Once again, only introduction
 
Interesting concept ...
Interesting concept ...
 
Real World HTML Parser
Real World HTML Parser The two fundamental use-cases that are handled by the parser are extraction and transformation (the syntheses use-case, where HTML pages are created from scratch, is better handled by other tools closer to the source of data). Whil
 
XML DOM-lite parser and writer
Summary This article provides a simple method for creating valid XML and a simple DOM-like (Document Object Model) parser. This method is useful for small applications that need simple XML functionality without the size and complexity of the full range d
 
Free SOAP Monitor
Membrane SOAP Monitor is a free Web Services development tool for inspecting and manipulating SOAP messages. It acts as a SOAP proxy between a consumer and a producer. SOAP messages can be intercepted, viewed and modified.
 
iCal4j
iCal4j Overview iCal4j is a Java library used to read and write iCalendar data streams as defined in RFC2445. Providing both a parser and an object model, iCal4j allows you to either modify existing iCalendar data or create new data models. Validation
 
Using the ASM Toolkit for Bytecode Manipulation
Using the ASM Toolkit for Bytecode Manipulation Sometimes Java developers need to generate or change Java bytecode in the runtime. Is can be necessary for AOP or debugging, or even for performance optimization. There are several frameworks available that
 
VolatileBufferedToolkitImage Strategies
Ever wondered what kind of image to use in your application? Or what method to use in creating it? This article attempts to address this challenging topic.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.