Regex, get string value between two characters

前端 未结 4 1697
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 07:31

I\'d like to return string between two characters, @ and dot (.).

I tried to use regex but cannot find it working.

(@(.*?).)

Anybod

4条回答
  •  一整个雨季
    2020-12-03 08:01

    this is the best and fast to use

    function get_string_between ($str,$from,$to) {
    
        $string = substr($str, strpos($str, $from) + strlen($from));
    
        if (strstr ($string,$to,TRUE) != FALSE) {
    
            $string = strstr ($string,$to,TRUE);
    
        }
    
        return $string;
    
    }
    

提交回复
热议问题