Buyocat Posted October 19, 2006 Share Posted October 19, 2006 As in 6'2, I want to be find strings of the form:66'26'22 (I suppose I'd like up to two decimal points)6.2 (for those stubborn people who use odd punctuation)6,2 (for those stubborn people who use odd punctuation)6 2 (for those stubborn people who use odd punctuation)I have the following expresssion/^[1-9]?((.|,|\'|\s)([0-9]{1,2}))$/However while it successfully matches the above it also matches666666666Now I can see where perhaps three digits come from, though I'm not sure why it didn't demand something from the punctuation group, but I don't clueless as to how there could be 4 digits.Any help plucking out these faulty matches would be much appreciated!Buyo Link to comment https://forums.phpfreaks.com/topic/24463-matching-heights-debug/ Share on other sites More sharing options...
printf Posted October 20, 2006 Share Posted October 20, 2006 Maybe something like...untested but it should work![code]<?php$array = array ( '6', '6\'2', '6\'22', '6.2', '6,2', '6 2', '6 233', '77777', '7777');foreach ( $array AS $test ){ if ( preg_match ( "/^([1-9]{1}+[\.\,\' ]{1}+[0-9]{1,2}|[1-9]{1})$/", $test ) ) { echo $test . "<br />"; }}?>[/code]me! Link to comment https://forums.phpfreaks.com/topic/24463-matching-heights-debug/#findComment-111796 Share on other sites More sharing options...
obsidian Posted October 20, 2006 Share Posted October 20, 2006 [quote author=printf link=topic=112038.msg454907#msg454907 date=1161348149]Maybe something like...untested but it should work![/quote]tested, and it works ;) Link to comment https://forums.phpfreaks.com/topic/24463-matching-heights-debug/#findComment-111800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.