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 6584695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:34:09+00:00 2026-05-25T16:34:09+00:00

I have the following code: preg_replace(‘/[^\w-]/u’,’.’,’Bréánná MÓÚLÍN’); Which on server A (PHP 5.3.5) returns:

  • 0

I have the following code:

 preg_replace('/[^\w-]/u','.','Bréánná MÓÚLÍN');

Which on server A (PHP 5.3.5) returns:
“Bréánná.Móúlín” (as it should)

However, on server B (PHP 5.2.11) it returns:
“Br..n..M..l.n” (not what what I want at all)

Am I right in thinking that this is down to whether or not PCRE_UCP was set when the whole thing was compiled?

Is there any way of overriding this if this is the case?

Failing that, is there any way of easily replacing such characters with a ‘standard’ equivalent? (Like utf8_decode but more expansive)

  • 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-05-25T16:34:09+00:00Added an answer on May 25, 2026 at 4:34 pm

    I am not sure whether PCRE_UCP defined during compilation affects preg_replace(), but a work-around to your problem is to use the multibyte string function mb_ereg_replace():

    <?php
    mb_internal_encoding("UTF-8");
    mb_regex_encoding("UTF-8");
    
    echo mb_ereg_replace('[^0-9A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-�̀-ͯ‿-⁀\\-]','.','Bréánná MÓÚLÍN');
    

    PHP 5.2 results: http://codepad.viper-7.com/UnZeyf

    EDIT: I originally thought that the multibyte ereg functions supported Unicode character type escapes, but this turns out not to be true. Instead, you need to determine the ranges of characters that you consider “letters”. I used the character ranges from the XML Standard’s definition of NameChar with the following Java program to generate the RegExp string (as apparently the multibyte ereg functions do not support Unicode character escape sequences, either):

    import java.io.*;
    
    public class SO7456963 {
        public static void main(String[] args) throws Throwable {
            Writer w = new OutputStreamWriter(new FileOutputStream("SO7456963.txt"), "UTF-8");
            w.write("[^0-9A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u0300-\u036F\u203F-\u2040\\\\-]");
            w.close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following symbols which preg_replace replaces: $replace = '/[^a-zA-Z0-9]/'; in my code I
I have the following code $body = preg_replace('/<img(.*?)src=(.+)/Ui','<img src=renderImage.php?image=\\2&width=<?=$img_width?>&url=<?=$mobiURL?>',$body); $body contains a whole html
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code: print <a href='.preg_replace($replace, '-', $name.-pid-.$id..html'>; and receive the following
I have the following code but I'm not a big fan of reg exp
I have the following which replace all of å, ø, æ .... etc to
I have the following code: $message = preg_replace($pattern, $this->get_bitly_url('$0'), $message); function get_bitly_url($url) { //
i want the regular expression to sanitize my data which should meet the following
I have the following PHP code to display my tag cloud. It seems if
I am using the following code: <?php $stock = $_GET[s]; //returns stock ticker symbol

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.