On Sun, 29 Aug 2021 06:00:56 -0700 (PDT) #5 wrote:
> // Now i'm using wxRegEx and this does'nt match
> wxString input(wxT(":
irc.example.net 372 mynick :- #Unicode The Unicode
> character coding system"));
> res = regex.Compile(wxT("^:(\\S+)\\s(\\d{3})\\s(.*):(.*)$"));
> if (res && regex.Matches(input))
> { ....
> // even though it works on here
https://regex101.com/r/ezPxTQ/1/
> what am i doing wrong?
No idea, but your regex works for me:
---------------------------------- >8 --------------------------------------
% cat wxregex_test.cpp
#include <wx/init.h>
#include <wx/crt.h>
#include <wx/regex.h>
int main(int argc, char **argv)
{
wxInitializer init;
if ( !init.IsOk() ) {
fprintf(stderr, "Failed to initialize wxWidgets.\n");
return 3;
}
if ( argc != 3 ) {
fprintf(stderr, "Usage: %s <pattern> <subject>.\n", argv[0]);
return 2;
}
wxRegEx rx;
if ( !rx.Compile(argv[1], wxRE_ADVANCED) ) {
fprintf(stderr, "Failed to compile regex /%s/.\n", argv[1]);
return 1;
}
if ( !rx.Matches(argv[2]) ) {
printf("Regex /%s/ doesn't match \"%s\".\n", argv[1], argv[2]);
return 1;
}
wxPrintf("Matched \"%s\" with %zu captures.\n", rx.GetMatch(argv[2]), rx.GetMatchCount());
return 0;
}
% g++ -g -Wall -o wxregex_test wxregex_test.cpp `wx-config --cxxflags --libs base`
% ./a.out "^:(\S+)\s(\d{3})\s(.*):(.*)$" ":
irc.example.net 372 mynick :- #Unicode The Unicode character coding system"
Matched ":
irc.example.net 372 mynick :- #Unicode The Unicode character coding system" with 5 captures.
---------------------------------- >8 --------------------------------------