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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:36:29+00:00 2026-05-12T23:36:29+00:00

I am using php preg_match and I have the original expression as: |(label\>Carried Price

  • 0

I am using php preg_match and I have the original expression as:

|(label\">Carried Price    </span> £)((.)*?)( </div)|

But I want to be able to able to be able to use the same basic expression but be able to search for Carried Price or Web Exclusive. I tried something like:

|(label\">[Carried Price|Web Exclusive]    </span> £)((.)*?)( </div)|

But no luck, any ideas? I also have to keep this structure of the regex as 3 groupings.

Additional the code I am using to test with example text

$page = '  <div class="web-exclusive-price">     <span class="label">Web Exclusive 
</span> £399.00 </div>
   <div class="web-only-label">     <span class="label">Offer not available in-store    </span>  </div>
    <div class="deliveryShortcut">        <span class="label"><a href="#deliverySection" onclick="navigateOpenSection(\'delivery\');">Standard Delivery</a></span> Free    </div>
';

$r = '|(label\">(?:Carried Price|Web Exclusive)    </span> £)((.)*?)( </div)|';

preg_match($r, $page, $matches);
  • 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-12T23:36:29+00:00Added an answer on May 12, 2026 at 11:36 pm

    You need round braces for this. Square braces [] are used to specify set of characters. Here is fixed regexp:

    $r = "'(label\">(?:Carried Price|Web Exclusive)\s+</span> £)((.)*?)( </div)'";
    

    Symbol (?:...) means non-capturing group. Here is more information about groups http://www.regular-expressions.info/named.html

    Update 1:

    Also regexp is not the best way to parse html. Look at allternavite way using SimpleXML.

    Update 2 (thanks to Tim Pietzcker):

    If you’re using | as regexp delimeter then you can’t use it inside regexp. I’ve replaces it with ' symbol. \s+ is used to match any number of spaces. Now your test code is working. See example above.

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

Sidebar

Related Questions

I have a regular expression to match usernames (which functions in PHP using preg_match
I'm trying to validate usernames in PHP using preg_match() but I can't seem to
Using PHP, I am trying to delete a record, but I want to check
I want to match a date-format in PHP using a regular expression. To keep
In PHP, I have a callback function using preg_match() (the exact contents are not
I want extract the path of images from a html page using PHP-preg_match_all(), the
using php and mysql I have two tables, a users table and a profiles
Using PHP ... This is for my personal use so I'm thinking maybe 3-4
Using PHP's Image and GD functions you can use the following method to finally
Using PHP and/or Codeigniter, I want to create some string templates to be store

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.