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; // Find the position of the last occurrence of "', beforeText)) { // The anchor does enclose specified text. if (match( '([Hh][Rr][Ee][Ff][ \t\n\r]*=)$0', beforeText, &hrefText)) { // Check the location of the found "href". startHref = strstr(beforeText, hrefText); if (startHref < strstr(beforeText, ">")) { // Now try to extract the URL if (match( pattern, substr( beforeText, startHref + strlen(hrefText), strlen(beforeText)), &url)) { return url; } } } } } } remainingText = substr( remainingText, startText + strlen(text), strlen(remainingText)); } return ""; } 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 ""; } string func getStringByBoundaries(source3, b1, b2) string source3, b1, b2; { int startPos, endPos; startPos = strstr(source3, b1); if (0 == startPos) { return ""; } startPos += strlen(b1); endPos = strstr(substr(source3, startPos, strlen(source3)), b2); if (0 == endPos) { return ""; } return substr(source3, startPos, endPos - 1); } string func getStringByPrefixAndBoundary(source4, prefix, b3) string source4, prefix, b3; { int startPos2, endPos2; startPos2 = strstr(source4, prefix); if (0 == startPos2) { return ""; } endPos2 = strstr( substr(source4, startPos2 + strlen(prefix), strlen(source4)), b3); if (0 == endPos2) { return ""; } return substr(source4, startPos2, strlen(prefix) + endPos2 - 1); } string func getStringByBoundaryAndPostfix(source5, b4, postfix) string source5, b4, postfix; { int startPos3, endPos3; startPos3 = strstr(source5, b4); if (0 == startPos3) { return ""; } startPos3 += strlen(b4); endPos3 = strstr( substr(source5, startPos3, strlen(source5)), postfix); if (0 == endPos3) { return ""; } return substr(source5, startPos3, strlen(postfix) + endPos3 - 1); } string func getStringByPrefixAndPostfix(source6, prefix2, postfix2) string source6, prefix2, postfix2; { int startPos4, endPos4; startPos4 = strstr(source6, prefix2); if (0 == startPos4) { return ""; } endPos4 = strstr( substr(source6, startPos4 + strlen(prefix2), strlen(source6)), postfix2); if (0 == endPos4) { return ""; } return substr(source6, startPos4, strlen(prefix2) + strlen(postfix2) + endPos4 - 1); } string func getStringByBoundariesEx(source3Ex, b1Ex, b2Ex) string source3Ex, b1Ex, b2Ex; { int startPosEx, endPosEx; string textA1Ex, textB1Ex; if (!match("(" + b1Ex + ")$0", source3Ex, &textA1Ex)) { return ""; } startPosEx = strstr(source3Ex, textA1Ex); startPosEx += strlen(textA1Ex); if (!match("(" + b2Ex + ")$0", substr(source3Ex, startPosEx, strlen(source3Ex)), &textB1Ex)) { return ""; } endPosEx = strstr(substr(source3Ex, startPosEx, strlen(source3Ex)), textB1Ex); return substr(source3Ex, startPosEx, endPosEx - 1); } string func getStringByPrefixAndBoundaryEx(source4Ex, prefixEx, b3Ex) string source4Ex, prefixEx, b3Ex; { int startPos2Ex, endPos2Ex; string textA2Ex, textB2Ex; if (!match("(" + prefixEx + ")$0", source4Ex, &textA2Ex)) { return ""; } startPos2Ex = strstr(source4Ex, textA2Ex); if (!match("(" + b3Ex + ")$0", substr(source4Ex, startPos2Ex + strlen(textA2Ex), strlen(source4Ex)), &textB2Ex)) { return ""; } endPos2Ex = strstr( substr(source4Ex, startPosEx + strlen(textA2Ex), strlen(source4Ex)), textB2Ex); return substr(source4Ex, startPos2Ex, strlen(textA2Ex) + endPos2Ex - 1); } string func getStringByBoundaryAndPostfixEx(source5Ex, b4Ex, postfixEx) string source5Ex, b4Ex, postfixEx; { int startPos3Ex, endPos3Ex; string textA3Ex, textB3Ex; if (!match("(" + b4Ex + ")$0", source5Ex, &textA3Ex)) { return ""; } startPos3Ex = strstr(source5Ex, textA3Ex); startPos3Ex += strlen(textA3Ex); if (!match("(" + postfixEx + ")$0", substr(source5Ex, startPos3Ex, strlen(source5Ex)), &textB3Ex)) { return ""; } endPos3Ex = strstr( substr(source5Ex, startPos3Ex, strlen(source5Ex)), textB3Ex); return substr(source5Ex, startPos3Ex, strlen(textB3Ex) + endPos3Ex - 1); } string func getStringByPrefixAndPostfixEx(source6Ex, prefix2Ex, postfix2Ex) string source6Ex, prefix2Ex, postfix2Ex; { int startPos4Ex, endPos4Ex; string textA4Ex, textB4Ex; if (!match("(" + prefix2Ex + ")$0", source6Ex, &textA4Ex)) { return ""; } startPos4Ex = strstr(source6Ex, textA4Ex); if (!match("(" + postfix2Ex + ")$0", substr(source6Ex, startPos4Ex + strlen(textA4Ex), strlen(source6Ex)), &textB4Ex)) { return ""; } endPos4Ex = strstr( substr(source6Ex, startPos4Ex + strlen(textA4Ex), strlen(source6Ex)), textB4Ex); return substr(source6Ex, startPos4Ex, strlen(textA4Ex) + strlen(textB4Ex) + endPos4Ex - 1); }