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

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

如何從 PHP 中的字符串獲取特定的字符串值?

如何從 PHP 中的字符串獲取特定的字符串值?

PHP
動漫人物 2021-06-28 13:08:12
我必須得到一個在字符串中包含“#”的值。Ex:$string = '#1234 Lorem ipsum is placeholder text commonly used in the graphic, #rm1345 print, and publishing industries for previewing layouts and visual mockups';Expected results: #1234 and #rm1345我應(yīng)該如何從 $string 中獲得上述結(jié)果?我嘗試了以下方法,但對我沒有幫助。$contents = str_word_count($string, 2);echo 'contents: <pre>';print_r($contents);echo '</pre>';請幫幫我。
查看完整描述

1 回答

?
幕布斯6054654

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超7個贊

這是您的正則表達(dá)式和生成的字符串


$string = '#1234 Lorem ipsum is placeholder text commonly used in the graphic, #rm1345 print, and publishing industries for previewing layouts and visual mockups';


$temp = preg_match_all('/(?<!\w)#\w+/', $string, $matches);


echo implode(' and ', $matches[0]);

輸出:


#1234 and #rm1345

工作演示。

正則表達(dá)式測試鏈接。(preg_match_all 匹配所有 # 附加單詞)。

來源鏈接


查看完整回答
反對 回復(fù) 2021-07-02
  • 1 回答
  • 0 關(guān)注
  • 309 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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