Skip to content

Conversation

Alcaro
Copy link

@Alcaro Alcaro commented Apr 11, 2025

Fixes #330

Fixes \x80-\xFF not matching high-ascii bytes

#include <ctre.hpp>
#include <regex>
#include <iostream>

int main()
{
    const char * b = "knäckebröd";

    auto k = ctre::search<R"([\x00-\x7F\x80-\xFF]*)">(b);
    std::cout << k.get<0>().to_view() << std::endl;

    auto k2 = ctre::search<R"(.*)">(b);
    std::cout << k2.get<0>().to_view() << std::endl;

    std::regex r{R"([\x00-\x7F\x80-\xFF]*)"};
    std::cmatch m;
    std::regex_search(b, m, r);
    std::cout << m[0] << std::endl;
}

https://godbolt.org/z/h4vxWajxb

@Alcaro
Copy link
Author

Alcaro commented Apr 11, 2025

Version 2: Also fixes \x00-\xFF matching wrong things (there are few bytes <= -1 && >= 0)

@Alcaro
Copy link
Author

Alcaro commented Apr 11, 2025

Version 3: Also fixes non-range chars in classes, so [a-zñ]+ will match piñata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[\x80-\xBF] - warning: comparison of integer expressions of different signedness
1 participant