Q:

why the simple regex about "*" pattern does not work?

the code is following
str="baaaacbd"
pattern = re.compile(r"a*")
mat = pattern.search(str)
print mat.group()

the output is nothing! it is disturbing! Why?

A:

First off, don't use python built-in type names as your variable names. Secondly, a* means match 0 or more of character a and re.search() will return the first occurrence of the pattern which is 0 occurrence. You can use groups() to see all the matches:
In [34]: pattern = re.compile(r"(a*)")

In [35]: mat = pattern.search(s)

In [36]: print(mat.group())

In [37]: print(mat.groups())
('',)

Or use a+ to match 1 or more character, which in this case is what you want:
In [38]: pattern = re.compile(r"a+")

In [39]: mat = pattern.search(s)

In [41]: print(mat.group())
aaaa

