scala.util.matching

class Regex

[source: scala/util/matching/Regex.scala]

class Regex(regex : java.lang.String, groupNames : java.lang.String*)
extends AnyRef
This class provides methods for creating and using regular expressions. It is based on the regular expressions of the JDK since 1.4.
Author
Thibaud Hottelier
Philipp Haller
Martin Odersky
Version
1.1, 29/01/2008
Parameters
regex - A string representing a regular expression
groupNames - A mapping from names to indices in capture groups
Value Summary
val pattern : java.util.regex.Pattern
The compiled pattern
Method Summary
def findAllIn (source : java.lang.CharSequence) : MatchIterator
Return all matches of this regexp in given character sequence as an iterator
def findFirstIn (source : java.lang.CharSequence) : Option[java.lang.String]
Return optionally first matching string of this regexp in given character sequence, None if it does not exist.
def findFirstMatchIn (source : java.lang.CharSequence) : Option[Match]
Return optionally first match of this regexp in given character sequence, None if it does not exist.
def findPrefixMatchOf (source : java.lang.CharSequence) : Option[Match]
Return optionally match of this regexp at the beginning of the given character sequence, or None if regexp matches no prefix of the character sequence.
def findPrefixOf (source : java.lang.CharSequence) : Option[java.lang.String]
Return optionally match of this regexp at the beginning of the given character sequence, or None if regexp matches no prefix of the character sequence.
def replaceAllIn (target : java.lang.CharSequence, replacement : java.lang.String) : java.lang.String
Replaces all matches by a string.
def replaceFirstIn (target : java.lang.CharSequence, replacement : java.lang.String) : java.lang.String
Replaces the first match by a string.
override def toString : java.lang.String
The string defining the regular expression
def unapplySeq (target : Any) : Option[List[java.lang.String]]
Tries to match target (whole match) and returns the matches.
Methods inherited from AnyRef
getClass, hashCode, equals, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
val pattern : java.util.regex.Pattern
The compiled pattern

Method Details
def unapplySeq(target : Any) : Option[List[java.lang.String]]
Tries to match target (whole match) and returns the matches.
Parameters
target - The string to match
Returns
The matches

def findAllIn(source : java.lang.CharSequence) : MatchIterator
Return all matches of this regexp in given character sequence as an iterator

def findFirstIn(source : java.lang.CharSequence) : Option[java.lang.String]
Return optionally first matching string of this regexp in given character sequence, None if it does not exist.

def findFirstMatchIn(source : java.lang.CharSequence) : Option[Match]
Return optionally first match of this regexp in given character sequence, None if it does not exist.

def findPrefixOf(source : java.lang.CharSequence) : Option[java.lang.String]
Return optionally match of this regexp at the beginning of the given character sequence, or None if regexp matches no prefix of the character sequence.

def findPrefixMatchOf(source : java.lang.CharSequence) : Option[Match]
Return optionally match of this regexp at the beginning of the given character sequence, or None if regexp matches no prefix of the character sequence.

def replaceAllIn(target : java.lang.CharSequence, replacement : java.lang.String) : java.lang.String
Replaces all matches by a string.
Parameters
target - The string to match
replacement - The string that will replace each match
Returns
The resulting string

def replaceFirstIn(target : java.lang.CharSequence, replacement : java.lang.String) : java.lang.String
Replaces the first match by a string.
Parameters
target - The string to match
replacement - The string that will replace the match
Returns
The resulting string

override def toString : java.lang.String
The string defining the regular expression