[Tutor] saving output in a text file
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Sat Jul 1 00:01:34 CEST 2006
Hi Hafsa,
> Can you guide me how to save the output returned by a regular expression
> group, into a text file? for instance for the following regular
> expression:
[regex cut]
> If the above regular expression is searched for in a file, how can i
> save the output matches from the group "name" into a new text file?
I'm not sure the problem you have has to do with regular expressions. Do
you mind if we change the question to something slightly different?
If you were given a function that takes a string and returns another
string, could you write a program that uses it and writes the result to
disk? For example, let's say that we have a string like "hello world",
process it through, well:
def double(s):
"double: string -> string
doubles up the input string s."
return s + s
Would you be able to write a program that takes "hello world", runs it
through double(), and writes out "hello worldhelloworld" to disk?
What I'm trying to isolate the problem: does it have to do with
input/output, or regular expressions, or something else?
Best of wishes!
More information about the Tutor
mailing list