Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ctre/pcre.gram
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mode_switch->s,[mode_singleline],<mode_switch2>
mode_switch->m,[mode_multiline],<mode_switch2>
mode_switch2->close | <mode_switch>

character_class->sopen,<set>,[set_make],sclose|sopen,caret,<set2a>,[set_make_negative],sclose
character_class->sopen,<set>,[set_make],sclose|sopen,minus,<set>,[set_make],sclose|sopen,caret,<set2a>,[set_make_negative],sclose
set-><setitem>,[set_start],<set2b>
set2a-><setitem2>,[set_start],<set2b>|epsilon,[set_empty]
set2b-><setitem2>,[set_combine],<set2b>|epsilon
Expand Down
3 changes: 2 additions & 1 deletion include/ctre/pcre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ struct pcre {
static constexpr auto rule(c, ctll::set<'!','$','\x28','\x29','*','+',',','.','/','0','1','2','3','4','5','6','7','8','9',':','<','=','>','?','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\"','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\x7B','|','\x7D'>) -> ctll::push<ctll::anything, push_character, range, set_start, set2b, set_make, ctll::term<']'>>;
static constexpr auto rule(c, _others) -> ctll::push<ctll::anything, push_character, range, set_start, set2b, set_make, ctll::term<']'>>;
static constexpr auto rule(c, ctll::term<'^'>) -> ctll::push<ctll::anything, set2a, set_make_negative, ctll::term<']'>>;
static constexpr auto rule(c, ctll::set<'-',']'>) -> ctll::reject;
static constexpr auto rule(c, ctll::term<'-'>) -> ctll::push<ctll::anything, push_character, set_start, set2b, set_make, ctll::term<']'>>;
static constexpr auto rule(c, ctll::term<']'>) -> ctll::reject;

static constexpr auto rule(class_named_name, ctll::term<'x'>) -> ctll::push<ctll::anything, ctll::term<'d'>, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_xdigit>;
static constexpr auto rule(class_named_name, ctll::term<'d'>) -> ctll::push<ctll::anything, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_digit>;
Expand Down
3 changes: 2 additions & 1 deletion single-header/ctre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,8 @@ struct pcre {
static constexpr auto rule(c, ctll::set<'!','$','\x28','\x29','*','+',',','.','/','0','1','2','3','4','5','6','7','8','9',':','<','=','>','?','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\"','_','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','\x7B','|','\x7D'>) -> ctll::push<ctll::anything, push_character, range, set_start, set2b, set_make, ctll::term<']'>>;
static constexpr auto rule(c, _others) -> ctll::push<ctll::anything, push_character, range, set_start, set2b, set_make, ctll::term<']'>>;
static constexpr auto rule(c, ctll::term<'^'>) -> ctll::push<ctll::anything, set2a, set_make_negative, ctll::term<']'>>;
static constexpr auto rule(c, ctll::set<'-',']'>) -> ctll::reject;
static constexpr auto rule(c, ctll::term<'-'>) -> ctll::push<ctll::anything, push_character, set_start, set2b, set_make, ctll::term<']'>>;
static constexpr auto rule(c, ctll::term<']'>) -> ctll::reject;

static constexpr auto rule(class_named_name, ctll::term<'x'>) -> ctll::push<ctll::anything, ctll::term<'d'>, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_xdigit>;
static constexpr auto rule(class_named_name, ctll::term<'d'>) -> ctll::push<ctll::anything, ctll::term<'i'>, ctll::term<'g'>, ctll::term<'i'>, ctll::term<'t'>, class_named_digit>;
Expand Down
4 changes: 4 additions & 0 deletions tests/matching3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,7 @@ TEST_NOT_MATCH(233, "[^]", "");
TEST_MATCH(234, "[^]+", "x");
TEST_MATCH(235, "[^]?", "");

// issue #346
TEST_MATCH(236, "[-A-Z]?", "Hello-World");
TEST_NOT_MATCH(237, "[A-Z]?", "Hello-World");
TEST_MATCH(238, "[\\-A-Z]?", "Hello-World");