中文翻譯(中國人寫的):
GOTO有害論
繁體只有找到討論:
Go To有害大論戰
2012年3月5日 星期一
2012年3月4日 星期日
find and replace
檔案中要放入 regular express 的字串,包含 . (dot),
先開 vim 把 . 換成 \. 放入 RE search 才會對。
:%s/\./\\./g
:%s/old-string/new-string/g
g 代表該行中每個符合 old-string 都要換成 new-string
如果沒有加 g,只有 :%s/old-string/new-string 的話,
只會替換該行第一個符合的 string,該行其後符合的都跳過。
python 中使用 regular express \b
diag = "pancreatic abscesses"
a = "I don't know what pancreatic abscesses is"
m = re.search( r"\b%s\b" %diag, a )
if m:
print( "Y" )
else:
print( "N" )
>>> Y
在python中使用 \b
1. %s 字串填入方式
2. raw string, ex: m = re.search( r"\bpancreatic abscesses\b", a )
3. 要加 r
Ref:
Does Python re module support word boundaries (\b)?
2012年3月3日 星期六
grep 與 cut
從檔案中找出所要的行,然後把所要的字切出來寫入檔案
grep "檢驗" lexicon.semantic | cut -f1 > test
cut 預設以 TAB 為分隔字元,若不是以 TAB 為分隔,再用 -d 選項
grep "檢驗" lexicon.semantic | cut -f1 > test
cut 預設以 TAB 為分隔字元,若不是以 TAB 為分隔,再用 -d 選項
訂閱:
意見 (Atom)