@@ -6,6 +6,8 @@ Fast compile-time regular expression with support for matching/searching/capturi
66
77You can use single header version from directory ` single-header ` . This header can be regenerated with ` make single-header ` .
88
9+ More info at [ compile-time.re] ( https://compile-time.re/ )
10+
911## What this library can do?
1012
1113``` c++
@@ -89,7 +91,7 @@ constexpr auto match(std::string_view sv) noexcept {
8991#### Extracting number from input
9092```c++
9193std::optional<std::string_view> extract_number(std::string_view s) noexcept {
92- if (auto m = ctre::match<"^ [a-z]++ ([0-9]++)$ ">(s)) {
94+ if (auto m = ctre::match<"[a-z]+([0-9]+) ">(s)) {
9395 return m.get<1>().to_view();
9496 } else {
9597 return std::nullopt;
@@ -105,7 +107,7 @@ struct date { std::string_view year; std::string_view month; std::string_view da
105107
106108std::optional<date > extract_date(std::string_view s) noexcept {
107109 using namespace ctre::literals;
108- if (auto [ whole, year, month, day] = ctre::match<"^ (\\ d{4})/(\\ d{1,2}+ )/(\\ d{1,2}+)$ ">(s); whole) {
110+ if (auto [ whole, year, month, day] = ctre::match<"(\\ d{4})/(\\ d{1,2})/(\\ d{1,2}) ">(s); whole) {
109111 return date{year, month, day};
110112 } else {
111113 return std::nullopt;
@@ -131,7 +133,7 @@ struct lex_item {
131133};
132134
133135std::optional<lex_item> lexer(std::string_view v) noexcept {
134- if (auto [m,id,num] = ctre::match<"^ ([a-z]++ )|([0-9]++)$ ">(v); m) {
136+ if (auto [m,id,num] = ctre::match<"([a-z]+)|([0-9]+) ">(v); m) {
135137 if (id) {
136138 return lex_item{type::identifier, id};
137139 } else if (num) {
@@ -150,7 +152,7 @@ This support is preliminary and probably the API will be changed.
150152```c++
151153auto input = " 123,456,768" sv;
152154
153- for (auto match: ctre::range<" ([0-9]++ ),?" >(input)) {
155+ for (auto match: ctre::range<" ([0-9]+),?" >(input)) {
154156 std::cout << std::string_view{match.get<0>()} << "\n";
155157}
156158```
0 commit comments