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

  • Home
  • SEARCH
  • 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 4558518
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:39:40+00:00 2026-05-21T17:39:40+00:00

My goal is to filter through a Microsoft Word Document (.docx) grabbing all Japanese

  • 0

My goal is to filter through a Microsoft Word Document (.docx) grabbing all Japanese kanji and kana.
The current code I am working with is the following:

preg_match_all('~[\x{4e00}-\x{9faf}]([\x{3040}-\x{309f}]) \= ([a-z]) \=+~u', $data, $matches);

According to some research I discovered the unicode values of Japanese text as follows: http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml

An example of the data I am working with looks like this:

時(とき) = toki = time; hour; occasion; momentを = wo = particle marking the direct object of the sentence(時 = time)超えて(こえて) = koete = cross

My end goal is to be able to run a preg_match_all fetching data in a similar pattern that looks like “超えて(こえて) = koete”
The information before the ( and the information inside ( ) and the romanization after between = =

The result I am looking for would be a returned array that looks like:

array(
    0 => array('時', 'とき', 'toki'),
    1 => array('超えて', 'こえて', 'koete')
);

The first result in each array includes both “Kanji, Hiragana, and possibly Katakana” while the 2nd result is only Hiragana and the third result is only regular alphabetic characters. I’m not too great with regex and add Japaense unicode and I’m clueless, any help would really be appreciated! 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-05-21T17:39:41+00:00Added an answer on May 21, 2026 at 5:39 pm

    You can use the special Unicode regex placeholders instead of the numeric ranges if you use the /u modifier:

    preg_match_all('/
        ([\p{Han}\p{Katakana}\p{Hiragana}]+)    # Kanji
        (?: [(]                                 # optional part: paren (
        ([\p{Hiragana}]+)                       # Hiragana
        [)] )?                                  # closing paren )
        \s*=\s*                                 # spaces and =
        ([\w\s;=]+)                             # English letters
        /ux',
        $source,  $matches, PREG_SET_ORDER
    );
    print_r($matches);
    

    I’ve notices the Hiragana in parens is optional, so I made your regex a bit more complex with (?: ... )? which optionalizes that part.

    Note that the result ordering is a bit different, because preg_match_all keeps the complete match string in index [0] usually:

    [0] => Array
        (
            [0] => 時(とき) = toki = time; hour; occasion; moment
            [1] => 時
            [2] => とき
            [3] => toki = time; hour; occasion; moment
        )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: Filter out all words in a list not starting with the specified character.
Goal: Produce an Excel document with information from 3 associated models that is similar
I want to filter out all entries in my access logs that have a
My goal is to collect all tweets containing the words France and Germany and
I have this list of items I want to filter through: <ul id=container> <li
I'm trying to filter many-to-many relationship by some through Class field. Quoting the Django
My goal is to move away from an ISAPI filter that was set up
I am developing a lexer grammar for C/C++ source code. The goal of the
My end goal is to create a checkbox that, when selected, checks all the
The goal of the code below is, if the email address in the text

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.