aeroswat Posted January 20, 2010 Share Posted January 20, 2010 I wanna use this in a preg_match and want to know if this will match to only strings that contain case insensitive letters preg_match("/[^a-z]/i",$str) Quote Link to comment https://forums.phpfreaks.com/topic/189223-would-this-match-letters-only-no-matter-case/ Share on other sites More sharing options...
.josh Posted January 21, 2010 Share Posted January 21, 2010 sure, that would work, though opposite of what you're asking. If it finds anything that is not a-z or A-Z it will return true. So true means the string has more than just letters, false means that it IS only a-z or A-Z if you want to have it return true if the string is only case insensitive letters, you would need to do this: preg_match("/^[a-z]+$/i',$str); Quote Link to comment https://forums.phpfreaks.com/topic/189223-would-this-match-letters-only-no-matter-case/#findComment-999078 Share on other sites More sharing options...
aeroswat Posted January 21, 2010 Author Share Posted January 21, 2010 sure, that would work, though opposite of what you're asking. If it finds anything that is not a-z or A-Z it will return true. So true means the string has more than just letters, false means that it IS only a-z or A-Z if you want to have it return true if the string is only case insensitive letters, you would need to do this: preg_match("/^[a-z]+$/i',$str); I got it to do what I needed it to do without even full knowing what I needed it to do lol It worked the way I wanted it to the way I wrote it. Thankyou for the help and explanation Quote Link to comment https://forums.phpfreaks.com/topic/189223-would-this-match-letters-only-no-matter-case/#findComment-999344 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.