CSC/ECE 517 Summer 2008/wiki1 1 mb: Difference between revisions
Line 29: | Line 29: | ||
[http://www.regular-expressions.info/reference.html Basic regular expression syntax] <br/> | [http://www.regular-expressions.info/reference.html Basic regular expression syntax] <br/> | ||
[http://www.regular-expressions.info/refadv.html Advanced regular expression syntax] | [http://www.regular-expressions.info/refadv.html Advanced regular expression syntax] <br/> | ||
[http://exampledepot.com/egs/java.util.regex/pkg.html java.util.regex Examples from The Java Developers Almanac 1.4] <br/> | |||
http://exampledepot.com/egs/java.util.regex/pkg.html |
Revision as of 01:40, 7 June 2008
Regular expression support in Java and Ruby
What are regular expressions?
Regular expressions provide an efficient way to match patterns against strings. Both Java and Ruby use a regular expression syntax similar to Perl.
Perl regular expression syntax
How regular expressions are handled in Java
In Java, regular expressions are supported using the java.util.regex package.
Package summary for java.util.regex
The java.util.regex package contains two classes:
The Pattern class and
the Matcher class.
Instances of the Pattern class are used to represent regular expressions. Instances of the Matcher class are used to match the regular expressions described by the Pattern object against strings. The Pattern class provides methods to facilitate splitting strings based upon provided regular expressions, while the Matcher class provides methods that allow patterns to be found, replaced, and examined further.
How regular expressions are handled in Ruby
In Ruby, regular expressions are supported via the Regexp class.
Class summary for Regexp
Code Examples
Other useful links
Basic regular expression syntax
Advanced regular expression syntax
java.util.regex Examples from The Java Developers Almanac 1.4