我想计算(在单个正则表达式中)字符串开头的所有空格.
我的想法:
$identSize = preg_match_all("/^( )[^ ]/", $line, $matches);
Run Code Online (Sandbox Code Playgroud)
例如:
$example1 = " Foo"; // should return 1
$example2 = " Bar"; // should return 2
$example3 = " Foo bar"; // should return 3, not 4!
Run Code Online (Sandbox Code Playgroud)
任何提示,我如何解决它?