By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,050 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,050 IT Pros & Developers. It's quick & easy.

serach file for regexp, return if found?

P: n/a
i want to search a document for a particular regexp and then store
that regexp to a file.

but search and match only returns matchobjects(what are those anyway?
i dont get what to do with them, do they contain true/false,
stringposition etc?)

how do i do:
for rows in file:
print regexp.find ## or something equiavlent
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On May 23, 9:10 am, notnorweg...@yahoo.se wrote:
but search and match only returns matchobjects(what are those anyway?
i dont get what to do with them, do they contain true/false,
stringposition etc?)
It's all covered in the docs:

http://docs.python.org/lib/module-re.html
http://docs.python.org/lib/match-objects.html
Jun 27 '08 #2

P: n/a
no**********@yahoo.se wrote:
i want to search a document for a particular regexp and then store
that regexp to a file.
but search and match only returns matchobjects(what are those anyway?
i dont get what to do with them, do they contain true/false,
stringposition etc?)
how do i do:
for rows in file:
print regexp.find ## or something equiavlent
Is this what you are trying to do:

for row in file('/etc/services'):
if re.match('^ssh', row):
print row
Yves.
http://www.SollerS.ca

Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.