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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:42:31+00:00 2026-06-01T17:42:31+00:00

I need to extract the words and phrases within a text. For example, the

  • 0

I need to extract the words and phrases within a text. For example, the text is:

Hello World, “Japan and China”, Americans, Asians, “Jews and Christians”, and semi-catholics, Jehovah’s witnesses

Using preg_split(), it should return the following:

  1. Hello
  2. World
  3. Japan and China
  4. Americans
  5. Asians
  6. Jews and Christians
  7. and
  8. semi-catholics
  9. Jehova’s
  10. witnesses

I need to know the RegEx for this to work (or is it possible?). Notice the rules, phrases are enclosed in quotes (“). Alphanumerics, single quotes (‘) and dashes (-) are considered part of the word (that’s why “Jehova’s” and “semi-catholics” are considered one word), the rest separated with spaces are considered as single words, while other symbols not mentioned are ignored

  • 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-01T17:42:32+00:00Added an answer on June 1, 2026 at 5:42 pm

    You can actually do it very simply with str_getcsv like this:

    // replace any comma or space by a singe space
    $str = preg_replace('/(,+[ ]+)|([ ]+)/', ' ', $str);
    // treat the input as CSV, the delimiters being spaces and enclusures double quotes
    print_r(str_getcsv($str, ' ', '"'));
    

    output:

    Array
    (
        [0] => Hello
        [1] => World
        [2] => Japan and China
        [3] => Americans
        [4] => Asians
        [5] => Jews and Christians
        [6] => and
        [7] => semi-catholics
        [8] => Jehovah's
        [9] => witnesses
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large set of real-world text that I need to pull words
I need to extract words that contain digits. ex:- Input - 3909B Witmer Road.
I need to take a paragraph of text and extract from it a list
I need to extract text from any kind of web page using regex in
I need to split a string and extract words separated by whitespace characters.The source
I need to extract text from the word document uploaded by the user. I
I have serbian-english words in .rtf format and I need to extract it from
My question is a little simillar to Extract specific words from text field in
I need to extract all MP3 titles from a fuzzy list in a list.
I need to extract and see the data in FileMaker Pro 5.5. Is there

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.