Jump to content

Hi, i need help in forming a regex ? pls...


jd2007

Recommended Posts

i want to find matches of anything like this :

 

<a href="(these chars- a to z, A to Z, 0 to 9, _, (, ))-page">(these chars- a to z, A to Z)</a>

 

i did this:

 

$subject=file_get_contents(--a link--);

preg_match_all('%/b^[a-zA-Z0-9_()]-page">[A-Za-z\s]/b%', $subject, $result, PREG_PATTERN_ORDER);

print_r($result[0]);

 

this is my regex:

%/b^[a-zA-Z0-9_()]-page">[A-Za-z\s]/b%

 

but i get no result...an empty array...why ?

Link to comment
https://forums.phpfreaks.com/topic/71959-hi-i-need-help-in-forming-a-regex-pls/
Share on other sites

do you mean this ?

 

<?php
$test = '<a href="(testing123_-,)-page">(testing123_-,)-page</a>';
if (preg_match('/[a-z0-9()_,-]*(?=-)-page/i', $test))
{
echo "found";
} else {
echo "nothinf found";
}

//also
//preg_match_all('/[a-z0-9()_,-]*(?=-)-page/si', $test, $result, PREG_PATTERN_ORDER);
//$result = $result[0];

?>

 

please move to RegEx Section!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.