i am reading.txt and.log extension files having entries below
$AV:3666,0000,0*
$AV:3664,0000,0*
but i want to remove extra characters and symbols (AV....0000,0*)so that i can have an entry like this
$:2226
$:2308
how can i go about it in python,below is the code i am using
source_path = 'C:\\Users\\User\\Downloads\\file1'
file_formats = ['.txt','.log']
filenames = []
for filename in os.listdir():
for file_format in file_formats:
if filename.endswith(file_format):
filenames.append(filename)
will appreciate your help
Take a look at my beutiful regex
import re
x = "$AV:3664,0000,0*"
line = re.sub('[AV,0000,0*]', '', x)
It's just amazing. Look at this spottles output.
$:3664
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.