So I am slightly new to Python but familiar with other scripting languages. How do you include a semicolon in a search string with Python correctly. Whenever I do, I assume python is interpreting it as a new code block and their for not returning the proper results. See sample below:
Sample text file:
<value> I; want; this; line; </value>
<value> And; this; line; </value>
<value> I dont want this line </value>
Code:
import os
import re
find = "<value>*;*"
filename = "C:\\temp\\Sample.txt"
with open (filename, 'r') as infile:
for line in infile:
if re.match(find, line):
print(line)
It is returning all lines rather than just the first and second lines. I have tried multiple different methods around this (including this method) but nothing seams to work. There has to be a simple way to do this, or is Python just really this annoying to work with?