Check for a hashtag (#) within a line. Python 2.7

521 views Asked by At

I need to search each line within a text file for a hash (#). I am using Python 2.7.

I have already implemented the cycle through each line, and can find other expressions but for some reason the code isn't recognising a '#' in any line.

Things I have tried:

if re.search(r'(?=.#.)',lines[b]):

if "#" in line:

if '\#' in line:

(line or lines[b] corresponds to the line which my for loop is currently looking at)

The text I am searching is made up of blocks which contains lines like:

L_EXPO #(

Any other ideas?

0

There are 0 answers