Hello,
On 9/27/07, Ak 756 <macro.peng@gmail.com> wrote:
> I have a .txt file which contains one line data as
>
> "George",33,"engineer, r&d department, this company","234-7554-344"
>
> I use name,age,memo,tel=File.open(filename).split(',') to collect values
> but get wrong value for memo and tel. I want string "engineer, r&d
> department, this company" not be splited by comma, how can I do that?
I'm sure there's a more elegant solution, but this worked for me
(assuming the string is stored in the variable s):
name, age, memo, tel = $1, $2, $3, $4 if s =~
/^"(.+?)",(\d+),"(.+?)","([-\d+]+)"/
Cam