我有字符串,例如:
bool dxDrawImage float posX, float posY, float width, float height, mixed image , float rotation = 0, float rotationCenterOffsetX = 0, float rotationCenterOffsetY = 0, int color = white, bool postGUI = false
bool dxUpdateScreenSource element screenSource, bool resampleNow =false
我需要从中获取零件,例如:
bool dxDrawImage
float posX
float posY
...
我写:
preg_match_all("/(bool|float|int)[a-zA-Z0-9\s=]+/", $txt, $ar);
打印_r($ar):
Array ( [0] => Array ( [0] => bool dxDrawImage float posX [1] => float posY [2] => float width [3] => float height [4] => float rotation = 0 [5] => float rotationCenterOffsetX = 0 [6] => float rotationCenterOffsetY = 0 [7] => int color = white [8] => bool postGUI = false ) [1] => Array ( [0] => bool [1] => float [2] => float [3] => float [4] => float [5] => float [6] => float [7] => int [8] => bool ) )
为什么这个正则表达式捕获bool dxDrawImage float posX
而不是
bool dxDrawImage
float posX
如何解决这个问题?