regex - Python regular expression for finding string in between the text file -
i'm working on python code extract specific strings on text file between ' '. here's code i'm working on:
import re pattern = "(\w+'*',)" open('c:\documents , settings\ash\desktop\strcount.txt', "r") text: line in text: print re.findall(pattern, line) and list of strings in text file
('flbc8u', 24) ('chvquw', 24) ('7fdm@', 24) ('15ii?', 24) ('h!ode', 24) ('rb6#u', 24) ('uamer', 24) ('6nmdj', 24) ('d-ms1', 24) ('ejf&b', 24) i wanted take string in middle of ' ' single quotation mark before comma , number , bracket ignored
s = "'flbc8u', 24" print re.findall("'([^']*)'", s)[0] flbc8u
Comments
Post a Comment