1BSON::Regex(3)        User Contributed Perl Documentation       BSON::Regex(3)
2
3
4

NAME

6       BSON::Regex - BSON type wrapper for regular expressions
7

VERSION

9       version v1.12.2
10

SYNOPSIS

12           use BSON::Types ':all';
13
14           $regex = bson_regex( $pattern );
15           $regex = bson_regex( $pattern, $flags );
16

DESCRIPTION

18       This module provides a BSON type wrapper for a PCRE regular expression
19       and optional flags.
20

ATTRIBUTES

22   pattern
23       A string containing a PCRE regular expression pattern (not a "qr"
24       object and without slashes).  Default is the empty string.
25
26   flags
27       A string with regular expression flags.  Flags will be sorted and
28       duplicates will be removed during object construction.  Supported flags
29       include "imxlsu".  Invalid flags will cause an exception.  Default is
30       the empty string.
31

METHODS

33   try_compile
34           my $qr = $regexp->try_compile;
35
36       Tries to compile the "pattern" and "flags" into a reference to a
37       regular expression.  If the pattern or flags can't be compiled, a
38       exception will be thrown.
39
40       SECURITY NOTE: Executing a regular expression can evaluate arbitrary
41       code if the re 'eval' pragma is in force.  You are strongly advised to
42       read re and never to use untrusted input with "try_compile".
43
44   TO_JSON
45       If the "BSON_EXTJSON" option is true, returns a hashref compatible with
46       MongoDB's extended JSON
47       <https://github.com/mongodb/specifications/blob/master/source/extended-
48       json.rst> format, which represents it as a document as follows:
49
50           {"$regularExpression" : { pattern: "<pattern>", "options" : "<flags>"} }
51
52       If the "BSON_EXTJSON" option is false, an error is thrown, as this
53       value can't otherwise be represented in JSON.
54

AUTHORS

56       •   David Golden <david@mongodb.com>
57
58       •   Stefan G. <minimalist@lavabit.com>
59
61       This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
62
63       This is free software, licensed under:
64
65         The Apache License, Version 2.0, January 2004
66
67
68
69perl v5.32.1                      2021-01-26                    BSON::Regex(3)
Impressum