1. Technology
Send to a Friend via Email

Regular Expression

By

Definition:

A regular expression defines a pattern that matches a certain set of strings. For example, imagine you had the following set of strings :

 Java is a programming language.
 My name is Fred.
 Java is fun.
 Yikes, it's not Java. 

You could use the following regular expression to match all the strings that start with the word "Java":

 Java.* 

Regular expressions have a specific syntax which can be used to build up a pattern. The above example can be broken into two different parts. Firstly the word "Java" specifies that the string must start with those four letters (case does matter e.g., the string "java is fun" would not be considered a match). The next two characters ".*" specify that zero or more characters can follow on in the string.

The java.util.regex package can be used with regular expressions. Its Pattern class outlines the regular expression syntax.

Glossary:

# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

  1. About.com
  2. Technology
  3. Java
  4. Java Glossary
  5. R
  6. Regular Expression - Definition for the Java Term: Regular Expression

©2014 About.com. All rights reserved.