Name

SPVM::Re - Short Description

Description

Re class in SPVM has methods for 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");

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);

If the string or the string in the string buffer $string_or_buffer at offset $$offset_ref to the length $length matches the regex(and with flags) $pattern_and_flags.

If matching succeeds, returns a Regex::Match object, otherwise returns undef.

If $length is less than 0, it is set to the string length of $string_or_buffer.

$$offset_ref is updated to the next position if matching succeeds.

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);

The string referenced or the string in the string buffer $string_or_buffer at offset $$offset_ref to the length $length is replaced with the string of $replace using the regex(and with flags) $pattern_and_flags.

If replacing succeeds, returns a Regex::ReplaceInfo object, otherwise returns undef.

If $length is less than 0, it is set to the string length of $string_or_buffer.

$$offset_ref is updated to the next position if matching succeeds.

The flags in $pattern_and_flags can contains "g" to replace all maching strings.

split

static method split : string[] ($pattern_and_flags : object of string|string[], $string : string, $limit : int = 0)

Splits $string using $pattern_and_flags, and returns the splited string.

Copyright & License

Copyright (c) 2025 Yuki Kimoto

MIT License