I'm trying to write PHP code to take a string like "abcabc" and compare it with a string like "abc123abc" and tell that the strings match if is treated as a wildcard. It's easy enough if only one is used but I need this to work for any number of 's. Only one of the strings being compared will have a * in it. This is proving quite hard to code, has anyone else already written code to do it? Thanks!

    if (ereg('abc.+abc$', 'abc123')) {
    echo "Match found.";
    } else {
    echo "No match found.";
    }

    This will match anything string that begins with abc, ends with abc, and has something inbetween. (i.e. "abc123abc" or "abc abc" but not "abcabc")

    Hope this helps.

      where can I get info on regular expressions? I don't understand how to build them....

        Write a Reply...