ruby - Finding characters before a word in a string -


I have data pulled from an xlsx file that looks like this:

  [6, 2] = & gt; "Comment", [6, 3] = & gt; "Complaint", [6, 4] = & gt; "Inquire"  

I want to find the array Return the value of second number to the first bracket, search for complaint search 3 Should be back Any help is appreciated.

NB - Updated alarms to the alarms for the array. Removed string conversion in OP

  'roo' today_file = (File.dirname (__ FILE__) + '/output/today-report.xlsx' is required) def by_value (data, value) found = data Search | Kashmir, V. V == value found and found [0] [1] end data = Roo :: Excelx.new (today_file) output = bi_view (data, "complaint"). This returns the output  

While returning this return 'nil'

The array is produced in this form as follows:

 < Code> {[1, 1] = & gt; "Today's day - 02/10/14", [1, 4] => "Another comment below the fold - scroll down", [2, 1] => "Tomorrow we are about service 11 Received. ", [4, 1] = & gt; "TYPE", [6, 1] = & gt; "", [6, 2] = & gt; "Comment", [6, 3] = & gt; "Complaint", [6, 4] = & gt; "[Overall (type)", [7, 1] = & gt; "Editorial and other questions", [7, 2] = & gt; 1.0, [7, 3] = & gt; [6, 5] = & gt; ; 7.0, ...}  

This is a strange requirement how to do it.

  word = "complaint" data_string [/, (\ d +) \] = & gt; "# {Regexp.escape (word)}" /, 1] # = & gt; "3"  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -