在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Python/ 搜索和匹配
文本翻譯
提取URL地址
處理PDF
塊分類
搜索和匹配
大寫轉(zhuǎn)換
提取電子郵件地址
字符串的不變性
文本處理狀態(tài)機
雙字母組
閱讀RSS提要
單詞替換
WordNet接口
重新格式化段落
標(biāo)記單詞
向后讀取文件
塊和裂口
美化打印數(shù)字
拼寫檢查
將二進制轉(zhuǎn)換為ASCII
文本分類
文字換行
頻率分布
字符串作為文件
約束搜索
詞干算法
符號化
同義詞和反義詞
過濾重復(fù)的字詞
刪除停用詞
Python文本處理教程
文字摘要
段落計數(shù)令牌
語料訪問
文字改寫
文本處理簡介
處理Word文檔
Python文本處理開發(fā)環(huán)境
排序行

搜索和匹配

使用正則表達(dá)式有兩個基本操作看起來相似但有顯著差異。 re.match()僅在字符串的開頭檢查匹配,而re.search()檢查字符串中任何位置的匹配。 這在文本處理中起著重要作用,因為通常必須編寫正確的正則表達(dá)式來檢索用于情感分析的文本塊作為示例。

import re

if  re.search("tor", "Tutorial"):
        print "1. search result found anywhere in the string"

if re.match("Tut", "Tutorial"):
         print "2. Match with beginning of string" 

if not re.match("tor", "Tutorial"):
        print "3. No match with match if not beginning" 



# Search as Match

if  not re.search("^tor", "Tutorial"):
        print "4. search as match"

當(dāng)我們運行上面的程序時,得到以下輸出 -

1. search result found anywhere in the string
2. Match with beginning of string
3. No match with match if not beginning
4. search as match

上一篇:塊分類下一篇:標(biāo)記單詞