第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

找到數(shù)字后如何獲取字符串的剩余部分

找到數(shù)字后如何獲取字符串的剩余部分

PHP
蕪湖不蕪 2022-10-28 15:28:27
找到數(shù)字后如何獲取字符串的剩余部分。例 1) hello12cool4here輸出應(yīng)該是:2cool4here例 2) hel3lo12cool4here輸出應(yīng)該是:lo12cool4here
查看完整描述

2 回答

?
慕工程0101907

TA貢獻(xiàn)1887條經(jīng)驗 獲得超5個贊

使用正則表達(dá)式:


preg_match('/^\D*\d(.*)/', 'hello12cool4here', $matches);

echo($matches[1]);    // 2cool4here

preg_match('/^\D*\d(.*)/', 'hel3lo12cool4here', $matches);

echo($matches[1]);    // lo12cool4here

preg_match('/^\D*\d(.*)/', '42lo12cool4here', $matches);

echo($matches[1]);    // 2lo12cool4here


查看完整回答
反對 回復(fù) 2022-10-28
?
慕仙森

TA貢獻(xiàn)1827條經(jīng)驗 獲得超8個贊

您可以遍歷所有字符并測試它們是否為數(shù)字,找到第一個時返回:


$str='hello12cool4here';


for( $i=0; $i< strlen( $str ); $i++ ){

    if( is_numeric( substr($str,$i,1) ) )exit( substr( $str, $i+1 ) );

}

或?qū)⑵浞湃牒瘮?shù)中:


function findremainder( $str ){

    for( $i=0; $i< strlen( $str ); $i++ ){

        if( is_numeric( substr($str,$i,1) ) )return( substr( $str, $i+1 ) );

    }

    return $str;

}



echo findremainder( $str );


查看完整回答
反對 回復(fù) 2022-10-28
  • 2 回答
  • 0 關(guān)注
  • 94 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號