regex lib bug: \u and icase

Hello, Regular expressions "[\u]" and "\u", unlike "[[:upper:]]", will not match any letters when the icase flag is set. Similarly, "\U" will match anything. Expressions "\l" and "\L" seem to be fine due to the lower_case_map[] translation. My suggestion would be to replace classes.push(traits_type::char_class_upper); and the like by classes.push((_flags & regex_constants::icase) ? traits_type::char_class_alpha : traits_type::char_class_upper); in the 'syntax_u/U/l/L' cases in set_compile() and set_expression(). This approach is currently taken in the 'syntax_open_set' case in set_compile(). John may have a different fix in mind, though. :-) Regards, Ralph

Regular expressions "[\u]" and "\u", unlike "[[:upper:]]", will not match any letters when the icase flag is set. Similarly, "\U" will match anything. Expressions "\l" and "\L" seem to be fine due to the lower_case_map[] translation.
My suggestion would be to replace
classes.push(traits_type::char_class_upper);
and the like by
classes.push((_flags & regex_constants::icase) ? traits_type::char_class_alpha : traits_type::char_class_upper);
in the 'syntax_u/U/l/L' cases in set_compile() and set_expression(). This approach is currently taken in the 'syntax_open_set' case in set_compile().
John may have a different fix in mind, though. :-)
Thanks, I'm actually in the process of rewriting all the expression parsing code, so yes the fix will be different, although for the time being, I'll commit the fix you suggested. John.
participants (2)
-
Benzinger, Ralph
-
John Maddock