cfad47cfa3/t3compiler/tads3/test/data/regex.t

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#include "tads.h"
2
#include "t3.h"
3
4
preinit() { }
5
6
main(args)
7
{
8
    for (;;)
9
    {
10
        local pat, str, match;
11
12
        "regular expression: "; pat = inputLine();
13
        if (pat == '')
14
            break;
15
        
16
        "string: "; str = inputLine();
17
18
        match = rexMatch(pat, str);
19
        if (match == nil)
20
            "No match.\n";
21
        else
22
        {
23
            "Match length = <<match>>\n";
24
            for (local i = 1 ; i < 9 ; ++i)
25
            {
26
                local g = rexGroup(i);
27
                if (g != nil)
28
                    "group <<i>> = '<<g[3]>>'\n";
29
            }
30
        }
31
32
        "\b";
33
    }
34
}