cooldude832 Posted July 18, 2007 Share Posted July 18, 2007 I'm trying to make a regex test for something likeĀ N is any integer <?php $string = "ly123"//or ly543 or ly1111 or ly12 or ly1 for examples if($string = "lyNNN" || "lyN" || "lyNNNN" || lyNN"){ //do something } ?> Link to comment https://forums.phpfreaks.com/topic/60611-solved-regex-with-a-format-of-lynnn-lynn-lynnn/ Share on other sites More sharing options...
cooldude832 Posted July 18, 2007 Author Share Posted July 18, 2007 I tried: <?php $re = "/ly[0-9]{1,4}/"; if (eregi($re,$afid)){ ?> but that is always true Link to comment https://forums.phpfreaks.com/topic/60611-solved-regex-with-a-format-of-lynnn-lynn-lynnn/#findComment-301520 Share on other sites More sharing options...
effigy Posted July 18, 2007 Share Posted July 18, 2007 preg_match('/\Aly\d{1,4}\z/', $string); Link to comment https://forums.phpfreaks.com/topic/60611-solved-regex-with-a-format-of-lynnn-lynn-lynnn/#findComment-301527 Share on other sites More sharing options...
cooldude832 Posted July 18, 2007 Author Share Posted July 18, 2007 thanks works Link to comment https://forums.phpfreaks.com/topic/60611-solved-regex-with-a-format-of-lynnn-lynn-lynnn/#findComment-301529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.