[英]Regular expression to check whether bracket [containing alphanumeric characters] exists after specific word in string
我需要正則表達式來檢查字符串中是否包含包含字母數字字符的方括號[]。 方括號應放在Subject:
詞之后。
sometext..Subject: Auto Reply Re: Some information, anything [0000] continue with anything
我有正則表達式為preg_match('#\\[(.*?)\\]#', $text, $match); print $match[1];
preg_match('#\\[(.*?)\\]#', $text, $match); print $match[1];
它應該返回0000
作為輸出
這將找到“主題”並捕獲方括號中的以下內容。
$text ="sometext [1111] ..Subject: Auto Reply Re: Some information, anything [0000] continue with anything";
preg_match('#Subject.*?\[(.*?)\]#', $text, $match);
print $match[1]; //0000
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.