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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:46:06+00:00 2026-05-26T06:46:06+00:00

hello im just having a problem here with PREG_MATCH_ALL() lets say i have 2

  • 0

hello im just having a problem here with PREG_MATCH_ALL()
lets say i have 2 strings …
Save You
and
What If Uploader Name
i need to retreive Save You so i’m using the folowing paterns

preg_match_all('/<span id="title.*">(.*)<\/span>/i',,);

as a result i get

Save You
Uploader Name

I think this is because it’s taking the last any way to fix it ? or like matching the first ? thank you

EDIT:

<a href="#" onclick="searchActions.showLyrics('14840_100733666_21',9965243); return false;">Can&#39;t Keep My Hands Off You</a></span>

get as result

<a href="Your Love Is A Lie"</a>

with

/<span id="title(.*?)">(.*?)<\/span>/i
  • 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-26T06:46:06+00:00Added an answer on May 26, 2026 at 6:46 am

    The reason is that .* is greedy. The first .* (right after title) will swallow as many characters as it can, and then backtrack from the end of the string until the rest of the regexp can match.

    To fix it, either use the ungreedy version .*?, and/or replace the . with some character class that can’t match a quote (such as [^"]):

    preg_match_all('/<span id="title[^"]*">(.*?)<\/span>/i', ..., ...);
    

    For more information, see http://www.php.net/manual/en/regexp.reference.repetition.php

    (Ps. Levi Morrison is right — this is not a good way to parse HTML. Use a real HTML parser, such as DOMDocument::loadHTML().)

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

Sidebar

Related Questions

Hello i have just started learning mvc2 and im having a problem with the
Hello i am just Studying 3-tier Application. I am now having a problem with
Hello I just started CodeIgniter . I am having problem in loading view. My
Hello ladies and gents, I'm having a bit of problem with accept() . I
Hello everyone I am just learning my first programming language and have just corrected
I have a problem and a question with using Strings. The problem I am
I have a SharePoint web part (essentially just a Hello World app) that I
Code can be found here: http://www.myhorizon.ca/client_central/sortable_test.php Hello folks of Stackoverflow, I have a list
Hello good people of stackoverflow, I am having a weird problem while following Adam
So say I have a node structure like: <Row> <Column Name=Primary Number>1</Column> <Column Name=Secondary

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.