Anklang-0.3.0.dev956+gd75ac925 anklang-0.3.0.dev956+gd75ac925
ASE — Anklang Sound Engine (C++)

« « « Anklang Documentation
Loading...
Searching...
No Matches
regex.hh
Go to the documentation of this file.
1 // This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2#pragma once
3
4#include <ase/cxxaux.hh>
5
6namespace Ase {
7
9class Re final {
10public:
11 enum Flags : int32_t {
12 DEFAULT = 0,
13 ERE = 1 << 0, // Posix Extended
14 I = 1 << 4, // IGNORECASE
15 M = 1 << 5, // MULTILINE
16 N = 1 << 6, // NO_AUTO_CAPTURE
17 S = 1 << 7, // DOTALL
18 X = 1 << 8, // EXTENDED
19 XX = 1 << 9, // EXTENDED_MORE
20 J = 1 << 10, // DUPNAMES
21 U = 1 << 11, // UNGREEDY
22 };
23 static StringS findall (const String &regex, const String &input, Flags = DEFAULT);
24 static ssize_t search (const String &regex, const String &input, Flags = DEFAULT);
25 static String grep (const String &regex, const String &input, int group = 0, Flags = DEFAULT);
26 static String sub (const String &regex, const String &subst, const String &input, Flags = DEFAULT);
27 static String sub (const String &regex, const String &subst, const String &input, uint count, Flags = DEFAULT);
28};
29extern constexpr inline Re::Flags operator| (Re::Flags a, Re::Flags b) { return Re::Flags (int32_t (a) | int32_t (b)); }
30
31} // Ase
32
Wrapper for std::regex to simplify usage and reduce compilation time.
Definition regex.hh:9
static String sub(const String &regex, const String &subst, const String &input, Flags=DEFAULT)
Substitute regex in input by sbref with backreferences $00…$99 or $&.
Definition regex.cc:249
static String grep(const String &regex, const String &input, int group=0, Flags=DEFAULT)
Find regex in input and return matching string.
Definition regex.cc:225
static StringS findall(const String &regex, const String &input, Flags=DEFAULT)
Find regex in input and return non-overlapping matches.
Definition regex.cc:233
static ssize_t search(const String &regex, const String &input, Flags=DEFAULT)
Find regex in input and return match position >= 0 or return < 0 otherwise.
Definition regex.cc:217
The Anklang C++ API namespace.
Definition api.hh:8
uint32_t uint
Provide 'uint' as convenience type.
Definition cxxaux.hh:17
typedef int32_t
typedef ssize_t