Does any one know how to use a regular expression in mysql in order to ignore language accents such as á-é-í-ó-ú-ê-ç and so on in a search engine.

For example, if someone searches for "atomo", it should return the all the occurences of "atomo" and "átomo" as well.

Thanks.

    One thing you could do, which may return more matches than you're expecting, is to use a regexp to replace any characters with accents with an underscore, which is the single character wildcard.

    $search = ereg_replace( '[áéíóúêç]', '_', $search );

    Hope this helps...

    -Rich

      Thanks,

      that will work in a standard "like" search within mysql, but it doesn't seem to work when I use a REGEXP to compare the string at the database with the one typed.

      This Regular expression make sure the search is being made for whole words only:

      $query.= " c.keywords REGEXP '[[:<:]]".$vetor_busca[$i]."[[:>:]]'";

      if I use

      $vetor_busca[$i] = ereg_replace( '[áéíóú]', '_', $vetor_busca[$i] );

      nothing will be found.

      Does any one have a workaround for this problem?

      Thanks in advance.

      --regis

        Ah...I didn't realize you were using "regexp" instead of "like" in the sql statement.

        If you're using "regexp", you'll need to replace the '_' with '.'

        With 'like', the underscore matches a single character.

        With 'regexp', the period matches a single character.

        -Rich

          Thanks A lot.

          it works now.

          --regis

            Write a Reply...