|
|
Question : Ruby regular expression - count piece of text in a text field
|
|
Hello I have a csv file (approx 20000 lines) and I want to count the number of times the following text (On Hold)appears in a given field (Col4) Example .... Col1, Col2 , Col3, Col4, 1234, "abcd", 12/05/08, "This ticket place On Hold 12/05/07 and etc etc again placed on hold etc etc" 4567, "dfghfag", 14/05/08, "aaaaa \; On Hold-----On Hold rwg///sdf on hold ffff" when written to new file the result set will be ... Col1 Col2 Col3 Col4 1234, "abcd", 12/05/08, 2, 4567, "dfghfag", 14/05/08, 3
Any help much appreciated
Phil
|
Answer : Ruby regular expression - count piece of text in a text field
|
|
It might be not a bad idea to escape the \ in the path name I use \\ instead
This works like a charm for me, using your input file What is your ruby version?
|
|
|
|
|