StringScanner#matched() : matched() es un método de la clase StringScanner que devuelve la última string coincidente.
Sintaxis: StringScanner.matched()
Parámetro: valores de StringScanner
Devuelve: la última string coincidente.
Ejemplo 1 :
# Ruby code for StringScanner.matched() method # loading StringScanner require 'strscan' # declaring StringScanner c = StringScanner.new("Mon Sep 12 2018 14:39") c.match?(/\s+/) # matched() method puts "String Scanner matched form : #{c.matched()}\n\n" c.match?(/\w+/) # matched() method puts "String Scanner matched form : #{c.matched()}\n\n"
Producción :
String Scanner matched form : String Scanner matched form : Mon
Ejemplo #2:
# Ruby code for StringScanner.matched() method # loading StringScanner require 'strscan' # declaring StringScanner c = StringScanner.new("hellogeeks") c.match?(/\s+/) # matched() method puts "String Scanner matched form : #{c.matched()}\n\n" c.match?(/\w+/) # matched() method puts "String Scanner matched form : #{c.matched()}\n\n"
Producción :
String Scanner matched form : String Scanner matched form : hellogeeks
Publicación traducida automáticamente
Artículo escrito por mayank5326 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA