X-Git-Url: http://git.silcnet.org/gitweb/?p=crypto.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Ftests%2Ftest_silcregex.c;h=ba98bbe036ac87007523f9df0931658ad1987a59;hp=6e79cb0a83346fbd7062a9b589960bf3a48719b1;hb=f2462c5dd7e885e3daa00066fbf53e166fd361e0;hpb=c8fd78a59002c54dbc331a26839d042055e89d65 diff --git a/lib/silcutil/tests/test_silcregex.c b/lib/silcutil/tests/test_silcregex.c index 6e79cb0a..ba98bbe0 100644 --- a/lib/silcutil/tests/test_silcregex.c +++ b/lib/silcutil/tests/test_silcregex.c @@ -17,6 +17,28 @@ int main(int argc, char **argv) silc_log_set_debug_string("*regex*,*errno*"); } + regex = "(H..).(o..)"; + SILC_LOG_DEBUG(("Regex %s", regex)); + if (!silc_regex_compile(®, regex, 0)) + goto err; + + string = "Hello World"; + SILC_LOG_DEBUG(("Match %s", string)); + if (!silc_regex_match(®, string, num_match, match, 0)) + goto err; + for (i = 0; i < num_match; i++) { + if (match[i].start != -1) { + SILC_LOG_DEBUG(("Match start %d, end %d", match[i].start, + match[i].end)); + sub = silc_memdup(string + match[i].start, match[i].end - + match[i].start); + SILC_LOG_DEBUG(("Match substring '%s'", sub)); + silc_free(sub); + } + } + + silc_regex_free(®); + regex = "foo[0-9]*"; SILC_LOG_DEBUG(("Regex %s", regex)); if (!silc_regex_compile(®, regex, 0))