Print Name in Text File using python Regular expression
<p>I am looking for a name in a text file using python Regular expression.
Example: If I have a Name in the format like Brad Pitt or BRAD PITT in first 10 lines I want to print the name.
I am using the following code.</p>

<pre><code>import re

import sys

name=[sys.argv[1]]

for line in name:

     n=re.match("([A-Z]\d[A-Z]\d)", line) 
print "Name = "+str(n)
</code></pre>

<p>can any one please help me with the Solution. </p>

<p>Test this <a href="https://repl.it/DKaJ" rel="nofollow">one</a></p>

<pre><code>import re
import sys

# template content : TODO load from file or program args
name="Bratt PITT\nYour Name\nSimpleName\nWrong5Name\nThis is a Too complex Name"

for line in name.splitlines():
    n = re.match("^([A-Za-z\s]+)+$", line) 
    if(n):
        print "Name = " + str(n.group())
</code></pre>

python