Name
SPVM::Re - More Perlish Regular Expressions
Description
Re class in SPVM has methods for more Perlish regular expression.
Usage
use Re;
# Match
my $string = "Hello World"
my $match = Re->m($string, "^Hellow");
# Replace
my $string = "abc de abc";
my $replace_info = Re->s(my $_ = [$string], ["abc", "g"], "ABC");
$string = $_->[0];
# Split
my $parts = Re->split(" +", $string);
Class Methods
m
static method m : Regex::Match ($string_value : string|StringBuffer, $pattern_and_flags : string|string[], $offset_ref : int* = undef, $length : int = -1);
Calls Regex#new method given $pattern_and_flags. $pattern_and_flags is a pattern string or a string array that contains a pattern and flags.
And the returned Regex object calls Regex#match method given $string_value, $offset_ref, $offset_ref, $length, and returns its return value.
The Regex object is cached.
Exceptions:
Exceptions thrown by Regex#new method and Regex#match cound be thrown.
s
static method s : Regex::ReplaceInfo ($string_ref_value : mutable string|string[]|StringBuffer, $pattern_and_flags : string|string[], $replace : string|Regex::Replacer, $offset_ref : int* = undef, $length : int = -1);
Calls Regex#new method given $pattern_and_flags. $pattern_and_flags is a pattern string or a string array that contains a pattern and flags.
And the returned Regex object calls Regex#replace method given $string_ref_value, $offset_ref, $offset_ref, $length, and returns its return value.
The flags in $pattern_and_flags can contains "g"
to Regex#replace_g method instead of Regex#replace method.
The Regex object is cached.
Exceptions:
Exceptions thrown by Regex#new method and Regex#match cound be thrown.
split
static method split : string[] ($pattern_and_flags : string|string[], $string : string, $limit : int = 0)
Calls Regex#new method given $pattern_and_flags. $pattern_and_flags is a pattern string or a string array that contains a pattern and flags.
And the returned Regex object calls Regex#split method given $string, $limit, and returns its return value.
See Also
Copyright & License
Copyright (c) 2025 Yuki Kimoto
MIT License