Tandem Posted August 15, 2006 Share Posted August 15, 2006 Could anyone demonstrate to me a preg match that detects if the subject contains only spaces?I can't work it out myself.Thanks for any help. Quote Link to comment Share on other sites More sharing options...
effigy Posted August 15, 2006 Share Posted August 15, 2006 [code]<pre><?php $string = ' '; echo 'All spaces? '; echo preg_match('/^\x20+$/', $string) ? 'Yes' : 'No' ; ?></pre>[/code]If you're looking for blank lines, change the + to *, and \x20 to \s. \s is more commonly used to represent any kind of whitespace, not only spaces. Quote Link to comment Share on other sites More sharing options...
Tandem Posted August 15, 2006 Author Share Posted August 15, 2006 Works perfectly, thank you very much. Quote Link to comment 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.