Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8029791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:32:28+00:00 2026-06-05T00:32:28+00:00

I want to do typical highlight code. So I have something like: $valor =

  • 0

I want to do typical highlight code. So I have something like:

$valor = preg_replace("/(".$_REQUEST['txt_search'].")/iu", "<span style='background-color:yellow; font-weight:bold;'>\\1</span>", $valor);

Now, the request word could be something like “josé”. And with it, I want “jose” or “JOSÉ” or “José” etc highlighted too.

With this expression, if I write “josé”, it matches “josé” and “JOSÉ” (and all the case variants). It always matches the accented variants only. If I search “jose”, it matches “JOSE”, “jose”, “Jose” but not the accented ones. So I’ve partially what I want, cause I have case insensitive on accented and non-accented separately.

I need it fully combined, wich means accent (unicode) insensitive, so I can search “jose”, and highlight “josé”, “josÉ”, “José”, “JOSE”, “JOSÉ”, “JoSé”, …

I don’t want to do a replace of accents on the word, cause when I print it on screen I need to see the real word as it comes.

Any ideas?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:32:29+00:00Added an answer on June 5, 2026 at 12:32 am

    You can try to make a function to create your regex expression based on your txt_search, replacing any possible match to all possible matches like this:

    function search_term($txt_search) {
        $search = preg_quote($txt_search);
    
        $search = preg_replace('/[aàáâãåäæ]/iu', '[aàáâãåäæ]', $search);
        $search = preg_replace('/[eèéêë]/iu', '[eèéêë]', $search);
        $search = preg_replace('/[iìíîï]/iu', '[iìíîï]', $search);
        $search = preg_replace('/[oòóôõöø]/iu', '[oòóôõöø]', $search);
        $search = preg_replace('/[uùúûü]/iu', '[uùúûü]', $search);
        // add any other character
    
        return $search;
    }
    

    Then you use the result as a regex on your preg_replace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the typical emp table from which i want to fetch the hierarchical
I have a typical User model (username, password, name, etc). I want to allow
I have a typical pom.xml, and want to print the groupId, artifactId and version,
I have an typical CUSTOMER/ORDERS set of tables and I want to display the
I want to parse expressions like those in typical Haskell source. I get an
I want to bind a command to a comboboxitem much like a typical command
I want to have a link or something which could be inserted in an
I have a typical nested tree model and I want to build an array
So I have typical 1:M relationship: Car can have many Models I want to
We have a typical web-based login system. We want customers to have the ability

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.