Name

SPVM::Re - More Perlish Regular Expressions

Description

Re class in SPVM has methods for more Perlish regular expression.

Usage

use Re;

my $string = "Hello World"
my $match = Re->m($string, "^Hellow");

# ABC de ABC
my $string_ref = ["abc de abc"];
Re->s($string_ref, ["abc", "g"], "ABC");

my $parts = Re->split(" +", $string);

Class Methods

m

static method m : Regex::Match ($string_or_buffer : object of string|StringBuffer, $pattern_and_flags : object of 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_or_buffer, $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_or_buffer : object of string[]|StringBuffer, $pattern_and_flags : object of string|string[], $replace : object of 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_or_buffer, $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 : object of 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