PHP preg_match get in between string

后端 未结 5 1905
广开言路
广开言路 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:32

    It looks to me like you just have to get $match[1]:

    php > $file = "1232#hello world#";
    php > preg_match("/1232\\#(.*)\\#/", $file, $match);
    php > print_r($match);
    Array
    (
        [0] => 1232#hello world#
        [1] => hello world
    )
    php > print_r($match[1]);
    hello world
    

    Are you getting different results?

提交回复
热议问题