A little regex help
| From: | Gareth Hastings | Date: | Fri, 13 Dec 2002 18:21:30 +0000 |
| Subject: | A little regex help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128182@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to work out the regex needed to split either one of the
following lines
Windows 2000 Hotfix (Pre-SP4) See Q322842 for more information
Windows XP Hotfix (SP2) See Q327696 for more information
Into one of these
Windows 2000 Hotfix (Pre-SP4) See <a
href='http://support.microsoft.com/default.aspx?scid=kb;en-us;Q322842'>Q
322842</a> for more information
Windows XP Hotfix (SP2) See <a
href='http://support.microsoft.com/default.aspx?scid=kb;en-us;Q327696>Q3
27696</a> for more information
I can work out half of the expression but not the other half lol, I've
used a combination of ereg and split but I'm sure this can be done with
1 ereg statement. Here is my code
$ms = "http://support.microsoft.com/default.aspx?scid=kb;en-us;";
if (ereg("(\[See )([Q|q][0-9]+)( for more information\])", $name))
{
$sp = split("\[See ", $name);
ereg("([Q|q][0-9]+)( for more information\])", $sp[1], $qb);
$url = $sp[0] . "See <a href='$ms" . $qb[1] . "'
target='_blank'>" . $qb[1] . "</a> for more information";
}
Any ideas?
Gareth