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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:36:21+00:00 2026-05-13T19:36:21+00:00

I have preg_match_all(‘/[aäeëioöuáéíóú]/u’, $in, $out, PREG_OFFSET_CAPTURE); If $in = ‘hëllo’ $out is: array(1) {

  • 0

I have preg_match_all('/[aäeëioöuáéíóú]/u', $in, $out, PREG_OFFSET_CAPTURE);

If $in = 'hëllo' $out is:

array(1) {
[0]=>
  array(2) {
  [0]=>
    array(2) {
      [0]=>
      string(2) "ë"
  [1]=>
  int(1)
}
[1]=>
array(2) {
  [0]=>
  string(1) "o"
  [1]=>
  int(5)
  }
}
}

The position of o should be 4. I’ve read about this problem online (the ë gets counted as 2). Is there a solution for this? I’ve seen mb_substr and similar, but is there something like this for preg_match_all?

Kind of related: Is their an equivalent of preg_match_all in Python? (Returning an array of matches with their position in the string)

  • 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-13T19:36:21+00:00Added an answer on May 13, 2026 at 7:36 pm

    PHP doesn’t support unicode very well, so a lot of string functions, including preg_*, still count bytes instead of characters.

    I tried finding a solution by encoding and decoding strings, but ultimately it all came down to the preg_match_all function.

    About the python thing: a python regex matchobject contains the match position by default mo.start() and mo.end(). See: http://docs.python.org/library/re.html#finding-all-adverbs-and-their-positions

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

Sidebar

Related Questions

i have a little problem about preg_match_all and str_replace <? $source = 'hello @user_name,
I would like to ask about php's preg_match_all. suppose we have the sample string
I have a problem with preg_match_all that maybe you can help. I have a
currently, this is the preg_replace string that I have. $mtg_post['post_content'] = preg_replace([^\\x20-\\x7e], ,$ability); This
I have a string like this ch:keyword ch:test ch:some_text I need a regular expression
I have this text string: $text=::tower_unit::7::/tower_unit::<br/>::tower_unit::8::/tower_unit::<br/>::tower_unit::9::/tower_unit::; Now I want to get the value of
Consider that i have the string, $string = 'tag2 display=users limit=5'; Using the preg_match_all
/<table[\s]+cellspacing=0[\s]+class=cj(?:.*?)[\s]+id=(?:.*?)>(?:.*?)value=(.*?)(?:.*?)<td[\s]+class=dep>(.*?)<\/td>(?:.*)(?:<td[\s]+class=arr>(.*?)<\/td>)+(?:.*?)<\/table>/ This is my current regex string, used in PHP with preg_match_all() . I
I originally have this preg_match_all pattern for the HTML img tag, but how do
I have a string: This is a text, Your Balance left $0.10, End 0

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.