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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:07:13+00:00 2026-05-22T16:07:13+00:00

I am using PHP preg_match_all, and this is what I can get so far….

  • 0

I am using PHP preg_match_all, and this is what I can get so far….

[A-Za-z+\W]+\s[\d]

The only problem is that I need the \W to not be a ".

So I have tried:

[A-Za-z+[^\dA-Za-z"]\s?]+\s[\d]


[A-Za-z+]\s?+[^A-Za-z\d"]?\s[\d]

among other things, and it is just failing and I really can’t figure out why.

EDIT:

Here is the entire RegEx;

([A-Z][a-z]+\s){1,5}\s?[^a-zA-Z\d\s:,.\'\"]\s?
[A-Za-z+\W]+\s[\d]{1,2}\s[A-Z][a-z]+\s[\d]{4}

I split it into two line, the second line begins with what I posted.

Patterns trying to match:

    India – Adulterated Tea Powder Seized 18 April 2011
    India – Importer of Haldiram’s Petha Sweet Cubes Issuing Voluntary Recall 26 April 2011
    India – Undeclared Gluten Found in Sweets by Canadian Authorities 27 April 2011
    India – Adulteration Found in Edible Oils 28 April 2011
    India – Viral Disease Affects Chili Crop in Goa 28 April 2011
NOT ---->   Chili – India: Goa”. 8 April 2011
    Ivory Coast – Potential Cocoa Quality Decline despite Sufficient Surplus 11 April 2011
    Japan – Sanuki Kanzume Co. and Failure to Comply with FDA Standards 27 April 2011
    Madagascar – Toxic Sardines 14 April 2011
    Madagascar – Update: Toxic Sardines 26 April 2011
  • 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-22T16:07:13+00:00Added an answer on May 22, 2026 at 4:07 pm

    the pattern you are showing matches all letters and non word characters. The only thing not included in the pattern are numbers and you also want to not match the double quote.

    [^\d\"_]+\s\d
    

    Edit:

    I could be wrong, but from the sample input, it appears you are just trying to match all lines that don’t have a double quote. If so something like this is much easier and I’ve even grouped the date separate from the rest of the string. If you don’t need to group the sting/date then just remove all the parenthesis.

    <?php
    error_reporting(E_ALL);
    $str = "    India - Adulterated Tea Powder Seized 18 April 2011
        India - Importer of Haldiram’s Petha Sweet Cubes Issuing Voluntary Recall 26 April 2011
        India - Undeclared Gluten Found in Sweets by Canadian Authorities 27 April 2011
        India - Adulteration Found in Edible Oils 28 April 2011
        India - Viral Disease Affects Chili Crop in Goa 28 April 2011
        Chili - India: Goa\". 8 April 2011
        Ivory Coast - Potential Cocoa Quality Decline despite Sufficient Surplus 11 April 2011
        Japan - Sanuki Kanzume Co. and Failure to Comply with FDA Standards 27 April 2011
        Madagascar - Toxic Sardines 14 April 2011
        Madagascar - Update: Toxic Sardines 26 April 2011";
    preg_match_all("/^([^\"]+?)(\d?\d\s[a-z]+\s\d{4})$/im", $str, $m);
    echo '<pre>'.print_r($m, true).'</pre>';
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get real host name by not using $_SERVER['SERVER_NAME'] in PHP? Is
I'm currently using this regex in my php script to validate email addresses: preg_match_all(/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i,
In php, I have used preg_match_all() to find keywords (using the format %keyword%) in
Using PHP and preg_match_all I'm trying to get all the HTML content between the
I am looking for a regular expression using preg_match_all in PHP 5 that would
how can I get the link of this string using preg match all ?
I have table like this -> http://jsfiddle.net/jurisKaste/FvgeQ/ And I need to get array of
Using PHP, what's the fastest way to convert a string like this: 123 to
Using PHP and MySQL, I have a forum system I'm trying to build. What
Using PHP, I can convert MySQL data or static table data to csv, Excel,

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.