Revision: 34620
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 26, 2010 04:00 by webonomic
Initial Code
#Example row of data: 11/10/2010:Location: Home :Gender: M :Comment: I just wanted to say I had a great time at the party! :Email: [email protected] file = File.new("data.dlm", "r") File.open('output.txt', 'w') do |f1| while (line = file.gets) sub_string = line.scan(/:Comment:([^<>]*):Email:/imu).flatten f1.puts sub_string end end file.close
Initial URL
Initial Description
This regular expression used in Ruby will extract the characters between single or multi-character delimiters. It helps when you have strange delimiters such as \":delimeter1: text I want to grab goes here :delimiter2:\"
Initial Title
Strip characters from between two delimiters
Initial Tags
regex, data, text
Initial Language
Ruby