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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:15:30+00:00 2026-05-28T15:15:30+00:00

in an original code (Drupal core module) previous developer commented out the string: if

  • 0

in an original code (Drupal core module) previous developer commented out the string:

if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)) {

and instead, added:

if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/iu', $name)) {

Can you help me to understand what the difference between these two? What u modifier does? In php docs I found:

u (PCRE8)
This modifier turns on additional functionality of PCRE that is incompatible with Perl. Pattern strings are treated as UTF-8. This modifier is available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32. UTF-8 validity of the pattern is checked since PHP 4.3.5.

So I guess, previous developer had problems with interpreting special characters or something. I’m a bit puzzled, please advice on this.

  • 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-28T15:15:31+00:00Added an answer on May 28, 2026 at 3:15 pm

    The modifier is needed to process utf-8 encoded input properly. A pattern like \xC1 should match the unicode character U+00C1 (À). When you encode Á in utf-8 you get \xC3\x81, so \xC1 doesn’t match. The “u” modifier makes the algorithm use utf-8 so it does match.

    Basically, when you work with utf-8 encoded text this is what will happen:

    <?php
    var_dump(preg_match('/\xC1/u', 'Á'));
    // => int(1), matches
    
    var_dump(preg_match('/\xC1/', 'Á'));
    // => int(0), doesn't match
    ?>
    

    In your case the first regular expression [^\x80-\xF7] matches no (non-ascii) UTF-8 encoded text because of the way UTF-8 works. The second expression matches unicode characters outside of the range U+0080 – U+00F7, so it lets through all of cyrillic, greek, arab, hebrew, …

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

Sidebar

Related Questions

from this code will show in original color how can i change it to
Can I install code analysis in VSTS2008 SP1 without the original installation media? Is
Original code: (can be seen working here: http://sandbox.hokuten.net/jqrpg/ ) /* google.setOnLoadCallback(function() { */ $(function()
The program Reads out a textfile and emails it's contents The original code (with
Here is the original code: public class FruitGrower { public void growAFruit(String type) {
Can someone help me with some PHP please. The original code ~works, but the
I tried theming of radios in Drupal module overriding the following code in my
The original code: public List<Contact> GetContactListEntityCompiledLINQ() { if (entities == null) entities = new
here is the original code: public static int getInt () { Scanner in =
I've got a webapp whose original code base was developed with a hand crafted

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.