| 1 |
#include <tads.h> |
| 2 |
|
| 3 |
main(args) |
| 4 |
{ |
| 5 |
local r = new function(s, idx, orig) |
| 6 |
{ |
| 7 |
"callback: group(1) = <<rexGroup(1)[3]>>\n"; |
| 8 |
|
| 9 |
/* don't capitalize certain small words, except at the beginning */ |
| 10 |
if (idx > 1 && ['a', 'an', 'of', 'the', 'to'].indexOf(s.toLower()) != nil) |
| 11 |
return s; |
| 12 |
|
| 13 |
/* capitalize the first letter */ |
| 14 |
return s.substr(1, 1).toUpper() + s.substr(2); |
| 15 |
}; |
| 16 |
tadsSay(rexReplace('%<(<alphanum>+)%>', args[2], r, ReplaceAll)); |
| 17 |
"\n"; |
| 18 |
|
| 19 |
tadsSay(rexReplace('-(<digit>+)', args[2], '<font color=red>(%1)</font>', |
| 20 |
ReplaceAll)); |
| 21 |
"\n"; |
| 22 |
} |