pulsatrix 1.1.0
Loading...
Searching...
No Matches
unicode_regex.hpp
Go to the documentation of this file.
1
7#pragma once
8
9#include <cstddef>
10#include <memory>
11#include <optional>
12#include <string>
13#include <string_view>
14#include <vector>
15
16namespace pulsatrix {
17
36public:
38 explicit UnicodeRegex(std::string_view pattern);
41 UnicodeRegex& operator=(UnicodeRegex&&) noexcept;
42
44 struct Match {
45 size_t begin = 0;
46 size_t end = 0;
47 };
48
54 [[nodiscard]] std::vector<Match> find_all(std::string_view text) const;
55
57 [[nodiscard]] const std::string& pattern() const { return pattern_; }
58
59private:
60 struct Program;
61 std::string pattern_;
62 std::unique_ptr<Program> program_;
63};
64
65} // namespace pulsatrix
A compiled pattern, matched leftmost-first with backtracking as Oniguruma (which Hugging Face tokeniz...
Definition unicode_regex.hpp:35
UnicodeRegex(std::string_view pattern)
const std::string & pattern() const
The pattern as given.
Definition unicode_regex.hpp:57
UnicodeRegex(UnicodeRegex &&) noexcept
std::vector< Match > find_all(std::string_view text) const
Every non-overlapping match in valid UTF-8 text, scanning left to right. Empty matches are skipped.
Definition acquisition_functions.hpp:16
A match: a byte range [begin, end) of the subject.
Definition unicode_regex.hpp:44