Jump to content

Why do i get error below (preg_match) ?


jd2007

Recommended Posts

$string="<form method='get' action='script.php'></form>";
$regex="<form\s";
echo (preg_match($regex, $string)) ? 1 : 0;

 

i want it to show 1 if <form\s is found.

 

what i get is this:

 

Warning: preg_match() [function.preg-match]: No ending matching delimiter '>' found in C:\AppServ\www\regex1.php on line 5

0

Link to comment
https://forums.phpfreaks.com/topic/71225-why-do-i-get-error-below-preg_match/
Share on other sites

You need to use some character to denote the start and end of a regular expression within your string.  "|" and "/" are common characters to use, but you can use almost any character.  The first charcter in the string your original code has is "<" so the error message you posted is from not being able to find the matched closing charcter.

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.