string func getURLByTextEx(source2, expression2)
string source2, expression2;
{
int startText2, startA2, startHref2;
string text2, remainingText2, beforeText2, aOpenText2, hrefText2, url2;
string newExpression2, pattern2;
pattern2 = "([ \\t\\n\\r]*\"(([^\"]*)$0)\")|";
pattern2 += "([ \\t\\n\\r]*\\'(([^\\']*)$0)\\')|"; pattern2 += "([ \\t\\n\\r]*(([^ \\t\\n\\r]*)$0)[ \\t\\n\\r>])";
newExpression2 = "(" + expression2 + ")$0";
remainingText2 = source2;
while (1) {
if (!match(newExpression2, remainingText2, &text2)) {
break;
} else {
startText2 = strstr(remainingText2, text2);
beforeText2 = substr(remainingText2, 1, startText2 - 1);
startA2 = 0; // Find the position of the last occurrence of "', beforeText2)) {
// The anchor does enclose specified text.
if (match(
'([Hh][Rr][Ee][Ff][ \t\n\r]*=)$0',
beforeText2,
&hrefText2)) {
// Check the location of the found "href".
startHref2 = strstr(beforeText2, hrefText2);
if (startHref2 < strstr(beforeText2, ">")) {
// Now try to extract the URL
if (match(
pattern2,
substr(
beforeText2,
startHref2 + strlen(hrefText2),
strlen(beforeText2)),
&url2)) {
return url2;
}
}
}
}
}
}
remainingText2 =
substr(
remainingText2,
startText2 + strlen(text2),
strlen(remainingText2));
}
return "";
}
|