[Solved] How to I preg_match_all starts with “http” and ends with (“) or (‘) or white space(tabs, space, line break)


i suggest you use parse_url to fetch parts of urls!
Take a look at php.net

EDIT :

$file = file_get_contents( YOUR FILE NAME );
$lines = explode("\r\n", $file);
foreach( $lines as $line ){
$urlParts = parse_url( $line );
if( $urlParts['scheme'] == 'http' ){
 // Do anything ...
}
}

CHANGE :

oOk, i don’t know what’s your code!if you want to scrape html to find links i suggest this to you, it return href values of a tag to you :

preg_match_all ( "/<[ ]{0,}a[ \n\r][^<>]{0,}(?<= |\n|\r)(?:href)[ \n\r]{0,}=[ \n\r]{0,}[\"|']{0,1}([^\"'>< ]{0,})[^<>]{0,}>((?:(?!<[ \n\r]*\/a[ \n\r]*>).)*)<[ \n\r]*\/a[ \n\r]*>/ is", $source, $regs );

for ( $x = 0; $x < count ( $regs [ 1 ] ); $x ++ ) {
$tmp_array [ "link_raw" ] = trim ( $regs [ 1 ] [ $x ] );
}

Then use parse_url to check thoes

4

solved How to I preg_match_all starts with “http” and ends with (“) or (‘) or white space(tabs, space, line break)