Hi all, I just had a simple regular expression question. Why does this only match the first character in the string? it should find the 'a' no matter where it is in the string, right?

C:\Python26>python.exe
Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit (AMD64)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> print re.match ('a', 'dda')
None
>>> print re.match ('a', 'add')
<_sre.SRE_Match object at 0x0000000001D11370>
>>>

match() is for the beginning of a string
search() looks through the entire string

Thank's for that, i knew it had to be something simple. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.