列表4. 函数getURLByText
string func getURLByText(source, text)
string source, text;
{
int startText, startA, startHref;
string remainingText, beforeText, aOpenText, hrefText, url;
string pattern;
pattern = "([ \\t\\n\\r]*\"(([^\"]*)$0)\")|";
pattern += "([ \\t\\n\\r]*\\'(([^\\']*)$0)\\')|";
pattern += "([ \\t\\n\\r]*(([^ \\t\\n\\r]*)$0)[ \\t\\n\\r>])";
remainingText = source;
while (1) {
startText = strstr(remainingText, text);
if (0 == startText) {
break;
} else {
beforeText = substr(remainingText, 1, startText - 1);
startA = 0; |
列表5中定义的函数“getURLByTextEx”提供了类似但更强大的功能。它允许使用VU语言所支持的正则表达式来指定目标Anchor标签所围绕的字符串的模式。例如,getURLByTextEx(“
Hello world!
, “[Ss]urprise”)将返回“hello1.jsp”。

