Exemplo n.º 1
0
static DeprecatedString RegExpFromGlob(DeprecatedString glob)
{
    DeprecatedString result = glob;

    // escape regexp metacharacters which are NOT glob metacharacters

    result.replace(RegularExpression("\\\\"), "\\\\");
    result.replace(RegularExpression("\\."), "\\.");
    result.replace(RegularExpression("\\+"), "\\+");
    result.replace(RegularExpression("\\$"), "\\$");
    // FIXME: incorrect for ^ inside bracket group
    result.replace(RegularExpression("\\^"), "\\^");

    // translate glob metacharacters into regexp metacharacters
    result.replace(RegularExpression("\\*"), ".*");
    result.replace(RegularExpression("\\?"), ".");
   
    // Require the glob to match the whole string
    result = "^" + result + "$";

    return result;
}
Exemplo n.º 2
0
RegularExpression createSearchRegex(const String& query, bool caseSensitive, bool isRegex)
{
    String regexSource = isRegex ? query : createSearchRegexSource(query);
    return RegularExpression(regexSource, caseSensitive ? TextCaseSensitive : TextCaseInsensitive);
}
//------------------------------------------------------------------------------
bool ofxWebServerBaseRouteHandler::matchRoute(const URI& uri, const Settings& settings) {
    return RegularExpression(settings.path).match(uri.getPath());
}