[libc-commits] [libc] [libc][regex] Add bracket expressions and character ranges (PR #234895)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Fri Oct 23 04:53:15 PDT 2026


================
@@ -64,6 +64,91 @@ constexpr bool is_unimplemented_ere_escape(char c) {
   }
 }
 
+// Parses a single collating element [[.c.]] or equivalence class [[=c=]].
+ErrorOr<uint8_t> parse_coll_elem(cpp::string_view &rem) {
+  cpp::string_view close_delim = rem.starts_with("[.") ? ".]" : "=]";
+  rem.remove_prefix(2);
+  size_t delim_pos = 0;
+  while (delim_pos + 2 <= rem.size() &&
+         !rem.substr(delim_pos).starts_with(close_delim))
+    ++delim_pos;
+  if (delim_pos + 2 > rem.size())
+    return Error(REG_EBRACK);
----------------
labath wrote:

This looks like it's implementing string_view::find. I haven't looked if there are other places that would be able to use this, but it would probably be worth a follow-up PR to implement this in our string_view.

https://github.com/llvm/llvm-project/pull/234895


More information about the libc-commits mailing list