Hello all,

I am trying to use more regex but I can't seem to get this to work. The aim is to check inputs for either [url, [link or <a href:

$islink = false;

 foreach($_POST as $k => $v){
	 if((preg_match("/[url|[link|<a href/i", $v)) > 0 ){
	 	$islink = true;
	 }
 }

 #gather data in sanitised variables
 $name 		= make_safe($_POST['name']);
 $feedback 	= make_safe($_POST['feedback']);
 $refer 	= make_safe($_POST['refer']);

 if($name && $feedback && !$islink){//process}

The if keeps executing, Any help would be great

<?php
$subject = "<a href='google.com'>Google link</a>";
$pattern = "/url|link|href/";

preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
?>

You need to escape the bracket, because it is a reserved char in a regex.

preg_match("/\[url|\[link|<a href/i", $v)
commented: Solved my problem quickly and efficiently thanks +2

Thank you very much it is now working as expected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.