假設我有一段文字:注意:這是我正在閱讀的檔案,因此實際上并未在代碼中注釋掉
" ## BATTERY LIFE: Pretty medicore at 12 hours, the Creative, iAudio, Rio, and iRiver players last longer.
CUSTOMER SERVICE[-3]## CUSTOMER SERVICE: Awful. Listen to this one, remember the battery statement I made earlier.
##If your battery dies and it's still under warranty, guess what, you're out of luck, because Apple doesn't cover the battery in the iPod warranty.
##They have the nerve to charge you $30 for a warrantied iPod.
technical service[-3]## "
我想提取方括號之前的元素,例如,在我想要的這段文字中:客戶服務[-3]和技術服務[-3]
有沒有什么很酷的方法可以做到這一點(使用某些 Regex 應用程式),因為我現在很困惑。
uj5u.com熱心網友回復:
以正則運算式的方式解決。
演示:https : //regex101.com/r/mWsAHf/1
圖案: \w \w \[-?\d ]
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/383162.html
