Hello World

Be Happy!

Article title convert by regular expression


sample code

require 'securerandom'
path="$ ab -n 1000 -c 100 -g out.data"
path.gsub!(/[\^\`\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\|\;\:\'\"\,\.\<\>\'\"\/\?\[\]]/," ")
path.gsub!(/[ ]{1,}/, "-")
path.concat("-").concat(SecureRandom.hex[0,10])
path.gsub!(/[-]{2,}/, "-")
path.sub!(/^-/, "")

$irb
irb(main):069:0> require 'securerandom'
path="$ ab -n 1000 -c 100 -g out.data"
path.gsub!(/[\^\`\~\!\@\#\$\%\^\&\*\(\)\-\_\=\+\|\;\:\'\"\,\.\<\>\'\"\/\?\[\]]/," ")
path.gsub!(/[ ]{1,}/, "-")
path.concat("-").concat(SecureRandom.hex[0,10])
path.gsub!(/[-]{2,}/, "-")
path.sub!(/^-/, "")
=> false
irb(main):070:0> => "$ ab -n 1000 -c 100 -g out.data"
irb(main):071:0> => "  ab  n 1000  c 100  g out data"
irb(main):072:0> => "-ab-n-1000-c-100-g-out-data"
irb(main):073:0> => "-ab-n-1000-c-100-g-out-data-fa7480c38e"
irb(main):074:0> => nil
#irb (1) #regular_expression (4) #ruby (8)
List