亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

正則表達式 - 排除帶有單詞 (php) 的行

正則表達式 - 排除帶有單詞 (php) 的行

PHP
侃侃無極 2022-12-23 16:27:44
請幫忙,如果其中存在某個單詞,如何排除字符串的存在。例子:any text here my text any text word wrong any text any text here my text any text true any text any text here my text any text wrong any text此正則表達式標記所有行 ( https://regex101.com/r/rrgEp6/1 ):here([a-z, ]{0,70})((?:(?! word))) (wrong|true)在這種情況下需要排除單詞 - “單詞”:any text here my text any text true any text any text here my text any text wrong any text
查看完整描述

2 回答

?
墨色風雨

TA貢獻1853條經驗 獲得超6個贊

你可以使用

here((?:(?!\bword\b)[a-z ,]){0,70}) (wrong|true)

請參閱正則表達式演示

細節

  • here- 一個字符串

  • ((?:(?!\bword\b)[a-z ,]){0,70})- 第 1 組:小寫字母、空格或逗號,出現 0 到 70 次,不word以整個單詞字符序列開頭

  • - 空間

  • (wrong|true)- 第 2 組:wrongtrue字符序列。


查看完整回答
反對 回復 2022-12-23
?
蝴蝶刀刀

TA貢獻1801條經驗 獲得超8個贊

您可以使用

^(?!.*\bword\b).+

請參閱regex101.com 上的演示


查看完整回答
反對 回復 2022-12-23
  • 2 回答
  • 0 關注
  • 158 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號