所以我一直在爲一個小項目編寫一個遊戲腳本語言的語法高亮器。這一切都沒有阻礙,除了一部分:數字。PHP:preg_replace匹配一些數字,但不匹配
把這些線例如
(5:42) Set database entry {healthpoints2} to the value 100.
(5:140) Move the user to position (29,40) on the map.
欲突出顯示100上的端部,而不在突出的括號中的(5:42)或2。這些號碼並不總是在同一個地方,並不總是隻有一個號碼。
基本上,我需要一個正則表達式說:
「匹配不屬於任何地方之間{}和不匹配(#:#)任何數字模式。」
我一直在這裏呆了一天半,現在我正在拔頭髮,試圖弄清楚它。幫助與此將不勝感激! 我已經看過regular-expressions.info,並試圖RegexBuddy玩耍,但我只是沒有得到它:C
編輯:根據要求,這裏的一些行從腳本編輯器中右鍵複製。
(0:7) When somebody moves into position (**10** fhejwkfhwjekf **20**,
(0:20) When somebody rolls exactly **10** on **2** dice of **6** sides,
(0:31) When somebody says {...},
(3:3) within the diamond (**5**,**10**) - **20** //// **25**,
(3:14) in a line starting at (#, #) and going # more spaces northeast.
(5:10) play sound # to everyone who can see (#,#).
(5:14) move the user to (#,#) if there's nobody already there.
(5:272) set message ~msg to be the portion of message ~msg from position # to position #.
(5:302) take variable %var and add # to it.
(5:600) set database entry {...} about the user to #.
(5:601) set database entry {...} about the user named {...} to #.
你是什麼意思'突出'?請至少提供一個輸入示例和預期輸出。 – Madbreaks 2012-04-24 22:26:09