Jump to content

Preg match


Tandem

Recommended Posts

[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.
Link to comment
https://forums.phpfreaks.com/topic/17638-preg-match/#findComment-75191
Share on other sites

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.