Project

General

Profile

Bug #1572 ยป test.rb

kugel (Thomas Martitz), 06/06/2009 12:58 AM

 
# test.rb
#
# Copyright 2009 kugel. aka Thomas Martitz <thomas47@arcor.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.



strings = ["FS#", "FS#10048", "within a fs#10048 sentence", "fs# 9919", "fs100", "fs wow", "fs 1", "fs#132929921 "]

def to_url(__string, url)
number = __string.string.match(/[\d]+/).to_s
string = ""
puts url
url = sprintf (url, number)
puts url, number, number.class
return number
end

strings.each do |string|
if string.downcase.match(/fs[# ]{0,2}[\d]{3,6}[\D]*/)
printf "MATCH %s\n" , string
to_url($~, "http://www.rockbox.org/tracker/task/%s")
end
end
    (1-1/1)