Results 1 to 2 of 2

Thread: Questin about regular expression

  1. #1
    Join Date
    Nov 2012
    Thanked 0 Times in 0 Posts

    Default Questin about regular expression

    hi guys how are you ?

    i have question regarding regular expression

    let me get to the point

    for example

    HTML Code:
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <meta name="robots" content="index, follow" />
      <meta name="keywords" content="joomla, Joomla" />
      <meta name="description" content="Joomla! - the dynamic portal engine and content management system" />
      <meta name="generator" content="Joomla! 1.5 - Open Source Content Management" />
    i built one script using file get contents .. i used preg match to search for specific words from the above source

    suppose i just want to search for joomla version

    how i could do that please ..

    thank you

  2. #2
    Join Date
    Apr 2008
    Thanked 516 Times in 502 Posts
    Blog Entries


    Are you searching the entire document as *text* (not parsing it, using DOMDocument or similar)?

    If so, this "works," but relies on the <meta> tag being generated in a predictable manner
    (i.e., the first part must always be identical, and the version number must always immediately follow):
    PHP Code:

    # `$htmlstring` must be the html document you're searching

    if( preg_match'#<meta name="generator" content="Joomla\! ([0-9]\.[0-9])#ui',$htmlstring,$match ) ){
    $joomla_version $match[1];
    Using DOMDocument would be a more reliable way of getting the content attribute, and would allow a simpler regex. If you're trying to get more than this one value from the document, there might also be a significant performance improvement.

  3. The Following User Says Thank You to traq For This Useful Post:

    die-trying (12-07-2012)

Similar Threads

  1. Regular expression errors
    By techno_race in forum PHP
    Replies: 2
    Last Post: 02-25-2010, 06:34 PM
  2. regular expression problem
    By rogermsw in forum PHP
    Replies: 3
    Last Post: 12-06-2009, 02:14 AM
  3. Regular Expression Help
    By Moshambi in forum JavaScript
    Replies: 1
    Last Post: 04-17-2009, 07:29 AM
  4. Regular Expression Help CSV
    By JasonDFR in forum PHP
    Replies: 4
    Last Post: 10-26-2008, 06:49 PM
  5. Needed a JS Regular expression
    By jsnewbie in forum Looking for such a script or service
    Replies: 5
    Last Post: 06-26-2008, 05:24 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts