The complete code i have is
it seems to run fine but it returns no matches when i know the text file does infact have multiple strings that should match. Some examples of the strings in text files are as follows:
the output i am looking for would be along the lines of
Just wondering what im missing in order to actually get matches rather than it running through the code without errors and outputting nothing
You put a
at the front of your regex, so it only matches at the start of the string
; you could only match the very first line in your file. To allow it to match at the start of any line
in a multiline string, add the
Or just loop over your file by line and apply the unmodified regex:
which (assuming you wanted to find all matches) is likely a little slower than
on the whole file’s data at once when the file fits in memory, but means you can run against files of essentially arbitrary size.
If you have better answer, please add a comment about this, thank you!