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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:39:34+00:00 2026-05-31T20:39:34+00:00

I have never really used regular expressions all that much and as such i

  • 0

I have never really used regular expressions all that much and as such i have a few questions.

Basically i have built a simple class that returns text inbetween user specified tags.

function getData($tagname){
    $this->tagname = $tagname;
    $string = $this->dump;
    $pattern = "/<$tagname>(.*?)<\/$tagname>/s";
    preg_match($pattern,$string,$matches,PREG_OFFSET_CAPTURE);
    print_r($matches);
}

This is giving me the info required but its returning multiple copies in the array, im just wondering what the reason behind this is?

For example

$depData->getData('departureTime');

Returns

Array ( [0] => Array ( [0] => 2012/03/07 12:45:13 [1] => 41 ) [1] => Array ( [0] => 2012/03/07 12:45:13 [1] => 56 ) ) 

Im thinking that its something to do with my regex being to vague?

  • 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-31T20:39:36+00:00Added an answer on May 31, 2026 at 8:39 pm

    It’s giving giving you 2 results first is for the whole expresion <tag>(.*?)</tag> and the second result is for the result in the parentheses (.*?)

    Also I created an example for you to see the difference between the first capture (whole expression) and the parentheses capture (your serach).

    http://xrg.es/#1ompqhf

    Note: I replaced < and > with " for you to see more clearly what’s different.

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

Sidebar

Related Questions

I've never really used MS server or anything like that before, i have, however
This probably something really simple, but I have never used CAShapeLayers before, I imported
I have often heard this term being used, but I have never really understood
I'm used to doing Java programming, where you never really have to think about
I have never used Perl, but I am really impressed by the ack ,
I have never really done much C but am starting to play around with
I have experience with C++ but I've never really used Qt before. I'm trying
I have a beginner level Json question with MVC.net (I've never really used jquery
I really am a JS noob - I have never really used itbefore and
I am a mac user and have never really used a pc from the

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.