PHP preg_match get in between string

后端 未结 5 1891
广开言路
广开言路 2020-12-18 20:44

I\'m trying to get the string hello world.

This is what I\'ve got so far:

$file = \"1232#hello world#\";

preg_match(\"#1232\\#(.*)\\##\         


        
5条回答
  •  天命终不由人
    2020-12-18 21:22

    What if you want the delimiter to also be included in the array, this would be more usefull for preg_split where you might not want each array element to begin and end with the delimiters, the example im about to show would would include the delimeters inside the array values. this would be what you would need preg_match('/\#(.*?)#/', $file, $match); print_r($match); this would output array( [0]=> #hello world# )

提交回复
热议问题