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

Question

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?


Show source
| python   | search   | hashtag   | lines   2017-01-03 12:01 0 Answers

Answers ( 0 )

◀ Go back