Question: I have to read a text file line by line and extract some part of each line. I have a working code if the line I am reading is in the expected format but this is not always the case. There are errors in the file, i.e. some missing information or characters. So I want to skip these faulty lines. For this, I want to utilize `regular expression` module. I defined the regular expression I need. Lets say, `reg_exp_string` is going to be matched with the line I read. I want a full match, I do not want to searh some part of the text. If it is a full match return true, otherwise return false. The think is, I tried `re.match()` and it returns an object. I couldn't figure it out. What is the correct way to use it? It always returns an object if some part of the string matches with the regular expression. I want a full match only and get a boolean answer. How can I do this?

Answer: 
As mentioned in the [documentation](http://docs.python.org/library/re.html#regular-expression-syntax), `$` matches the end of a string. You can modify your regular expression to include `$` at the end. Example:

```
match_this = "abc12a" #expression you would like to match
dont_match_this = "abc12a9" #expression that returns partial matches from re.match

```

The old regular expression will match both `match_this` and `dont_match_this`:

```
old_reg_expr = "[a-z]+\d[a-z]+"

```

The new regular expression contains `$` and only returns a match if the string ends after the last element matched in the expression:

```
new_reg_expr = "[a-z]+\d[a-z]+$"

```

Alternatively, you could leave your old regular expression intact and just check to see if the ending position of the match is equal to the end of the string:

```
>>> m = re.match("[a-z]+\d[a-z]+", "abc12a9")
>>> m.end() == m.endpos
False

```
The documentation for match objects is [a little further down](http://docs.python.org/library/re.html#match-objects).