Re: [問題] 抓第一個出現的[
看板RegExp (正規表示式 Regular Expression)作者LPH66 (IWH68S0XZ8M89)時間17年前 (2008/03/29 15:13)推噓0(0推 0噓 0→)留言0則, 0人參與討論串2/4 (看更多)
※ 引述《vernc (cralvin)》之銘言:
: (C73) (同人誌) [LINDA Project] BLE七[ブリナナ] [BLEACH]
: ^
: 像上面的範例那位知道如何準確的抓到第一個[
: 只想到用下面、但換一個可能就出問題
: .{0,10}\[
: 在ultraedit用的,所以只能純regexp,perl不行
: thx
去設定改成unix syntax 就可以直接用 ^[^[]*[
(Advanced/Configuration/Search/Regular Expression Engine
右邊選Unix style Regular Expressions)
上面是這樣看:
^ 字首
[^[]* 不是[的一堆字 ([]中[無意義 只有]有結束意義)
[ 後面沒有]所以是literal [
--
個人以為ultraedit的syntax要拐個彎理解...
因為它的escape character是^ 不像unix syntax的escape character是\
(這也造成ultraedit syntax的"match行首"改成了%)
所以我都改成unix syntax來用
--
'You've sort of made up for it tonight,' said Harry. 'Getting the
sword. Finishing the Horcrux. Saving my life.'
'That makes me sound a lot cooler then I was,' Ron mumbled.
'Stuff like that always sounds cooler then it really was,' said
Harry. 'I've been trying to tell you that for years.'
-- Harry Potter and the Deathly Hollows, P.308
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.84
討論串 (同標題文章)
RegExp 近期熱門文章
PTT數位生活區 即時熱門文章