Regex
Type Aliases
type alias MatchQuery[a: Type, r: Eff] = Matcher[r] -> Result[String, a] \ r
SourceMatchQuery
is a read query applied to a the current match of a Matcher
.
Definitions
def breakAfterFirst(substr: { substr = Regex }, s: String): (String, String)
SourceFind the first instance of Regex substr
in string s
, return a pair of the
prefix of string s
up to and including sub
and the rest of string s
after sub
.
def breakBeforeLast(substr: { substr = Regex }, s: String): (String, String)
SourceFind the last instance of substr
in string s
, return a pair of the
initial string including substr
and suffix from substr
.
def breakOnFirst(substr: { substr = Regex }, s: String): (String, String)
SourceFind the first instance of Regex substr
in string s
, return a pair of the
prefix of string s
up to sub
and the rest of string s
including sub
.
def breakOnLast(substr: { substr = Regex }, s: String): (String, String)
SourceFind the last instance of substr
in string s
, return a pair of the
initial string including substr
and suffix from substr
.
def countSubmatches(substr: { substr = Regex }, s: String): Int32
SourceCount the occurrences of substr
in string s
.
def countSubmatchesWithBounds(substr: { substr = Regex }, start: { start = Int32 }, end: { end = Int32 }, s: String): Int32
SourceCount the occurrences of substr
in string s
within the bounds (start, end)
.
Returns 0 if the bounds are invalid.
def endsWith(suffix: { suffix = Regex }, s: String): Bool
SourceReturns true
if the string input
ends the regular expression Regex suffix
.
This will be slower than startsWith
because there is no primitive Java function
to call, instead the matches of patt
are iterated until the last one is found.
def flags(rgx: Regex): Set[Flag]
SourceReturn the flags used to build the Regex rgx
.
def getFirst(substr: { substr = Regex }, s: String): Option[String]
SourceReturn the content of the first occurence of substr
in s
from the left.
If the Regex substr
is not present in s
return None.
def getFirstWithBounds(substr: { substr = Regex }, start: { start = Int32 }, end: { end = Int32 }, s: String): Option[String]
SourceReturn the content of the first occurence of substr
in s
from the left within
the bounds (start, end)
.
If the Regex substr
is not present in s
or the bounds are invalid return None
.
def getFirstWithOffset(substr: { substr = Regex }, offset: { offset = Int32 }, s: String): Option[String]
SourceThis is getFirst
with a start offset.
If the Regex substr
is not present in s
return None.
def getLast(substr: { substr = Regex }, s: String): Option[String]
SourceReturn the content of the last occurence of substr
in s
from the left.
If the Regex substr
is not present in s
return None.
def getLastWithBounds(substr: { substr = Regex }, start: { start = Int32 }, end: { end = Int32 }, s: String): Option[String]
SourceReturn the content of the last occurence of substr
in s
from the left within
the bounds (start, end)
.
If the Regex substr
is not present in s
or the bounds are invalid return None
.
def getLastWithOffset(substr: { substr = Regex }, offset: { offset = Int32 }, s: String): Option[String]
SourceThis is getLast
with a start offset.
If the Regex substr
is not present in s
return None.
def getPrefix(substr: { substr = Regex }, s: String): Option[String]
SourceReturns Some(prefix)
of string s
if its prefix matches substr
.
def getSuffix(substr: { substr = Regex }, s: String): Option[String]
SourceReturns Some(suffix)
of string s
if its suffix matches substr
.
def indexOfFirst(substr: { substr = Regex }, s: String): Option[Int32]
SourceReturn the index of the first occurence of substr
in s
from the left.
If the Regex substr
is not present in s
return None.
def indexOfFirstWithBounds(substr: { substr = Regex }, start: { start = Int32 }, end: { end = Int32 }, s: String): Option[Int32]
SourceReturn the index of the first occurence of substr
in s
from the left within
the bounds (start, end)
.
If the Regex substr
is not present in s
or the bounds are invalid return None
.
def indexOfFirstWithOffset(substr: { substr = Regex }, offset: { offset = Int32 }, s: String): Option[Int32]
SourceThis is indexOfFirst
with a start offset.
If the Regex substr
is not present in s
return None.
def indexOfLast(substr: { substr = Regex }, s: String): Option[Int32]
SourceReturn the index of the last occurence of substr
in s
starting from the left.
If the Regex substr
is not present in s
return None.
def indexOfLastWithBounds(substr: { substr = Regex }, start: { start = Int32 }, end: { end = Int32 }, s: String): Option[Int32]
SourceReturn the index of the last occurence of substr
in s
from the left within
the bounds (start, end)
.
If the Regex substr
is not present in s
or the bounds are invalid return None
.
def indexOfLastWithOffset(substr: { substr = Regex }, offset: { offset = Int32 }, s: String): Option[Int32]
SourceThis is indexOfLast
with a start offset.
If the Regex substr
is not present in s
return None.
def indices(substr: { substr = Regex }, s: String): List[Int32]
SourceReturns the positions of the all the occurrences of substr
in s
.
If substr
regexp matches the empty string, positions where an empty match
has been recognized will be returned.
def indicesWithBounds(substr: { substr = Regex }, start: { start = Int32 }, end: { end = Int32 }, s: String): List[Int32]
SourceReturns the positions of the all the occurrences of substr
in s
within the bounds (start, end)
.
If substr
regexp matches the empty string, positions where an empty match
has been recognized will be returned.
Returns Nil
if there are no matches or the bounds are invalid.
def isMatch(rgx: Regex, s: String): Bool
SourceReturns true
if the entire string s
is matched by the Regex rgx
.
def isMatchWithBounds(rgx: Regex, start: { start = Int32 }, end: { end = Int32 }, s: String): Bool
SourceReturns true
if the entire string s
is matched by the Regex rgx
.
Returns false
if the entire string does not match or the bounds are invalid.
def isSubmatch(rgx: Regex, s: String): Bool
SourceReturns true
if the string input
is matched by the Regex rgx
at any position within the string s
.
def isSubmatchWithBounds(rgx: Regex, start: { start = Int32 }, end: { end = Int32 }, s: String): Bool
SourceReturns true
if the string input
is matched by the Regex rgx
at any position within the string s
that is within the bounds (start, end)
.
Returns false
if there is no match or the bounds are invalid.
def pattern(rgx: Regex): String
SourceReturn the regular expression string used to build this Regex.
def quote(s: String): String
SourceReturn the regular expression string that matches the the literal string s
.
def replace(src: { src = Regex }, dst: { dst = String }, s: String): String
SourceReturns string s
with every match of the Regex src
replaced by the string dst
.
def replaceFirst(src: { src = Regex }, dst: { dst = String }, s: String): String
SourceReturns string s
with the first match of the regular expression src
replaced by the string dst
.
def split(regex: { regex = Regex }, s: String): List[String]
SourceSplits the string s
around matches of the Regex regex
.
def startsWith(prefix: { prefix = Regex }, s: String): Bool
SourceReturns true
if the string s
starts the Regex prefix
.
def stripPrefix(substr: { substr = Regex }, s: String): Option[String]
SourceReturns Some(suffix)
of string s
if its prefix matches substr
.
def stripSuffix(substr: { substr = Regex }, s: String): Option[String]
SourceReturns Some(prefix)
of string s
if its suffix matches substr
.
def submatches(substr: { substr = Regex }, s: String): List[String]
SourceReturns the contents of the all the occurrences of substr
in s
.
Returns Nil
if substr
is the empty string.
def submatchesWithBounds(substr: { substr = Regex }, start: { start = Int32 }, end: { end = Int32 }, s: String): List[String]
SourceReturns the contents of the all the occurrences of substr
in s
within the bounds (start, end)
.
Returns Nil
if substr
is the empty string or the bounds are invalid.
def sumFlags(flags: Set[Flag]): Int32
SourceSum a list of flags to an Int32
bit mask.
def unmatchable(): Regex
SourceReturn the unmatchable Regex - a regular expression that will not match any input.