Ruby | StringScanner matched_size function Last Updated : 06 Aug, 2021 Comments Improve Suggest changes Like Article Like Report StringScanner#matched_size() : matched_size() is a StringScanner class method which returns the size of the most recent match Syntax: StringScanner.matched_size()Parameter: StringScanner valuesReturn: the size of the most recent match otherwise return nil Example #1 : Ruby # Ruby code for StringScanner.matched_size() method # loading StringScanner require 'strscan' # declaring StringScanner c = StringScanner.new("Mon Sep 12 2018 14:39") c.match?(/\s+/) # matched_size() method puts "String Scanner matched_size form : #{c.matched_size()}\n\n" c.match?(/\w+/) # matched_size() method puts "String Scanner matched_size form : #{c.matched_size()}\n\n" Output : String Scanner matched_size form : String Scanner matched_size form : 3 Example #2 : Ruby # Ruby code for StringScanner.matched_size() method # loading StringScanner require 'strscan' # declaring StringScanner c = StringScanner.new("hellogeeks") c.match?(/\s+/) # matched_size() method puts "String Scanner matched_size form : #{c.matched_size()}\n\n" c.match?(/\w+/) # matched_size() method puts "String Scanner matched_size form : #{c.matched_size()}\n\n" Output : String Scanner matched_size form : String Scanner matched_size form : 10 Comment More infoAdvertise with us Next Article Ruby | StringScanner rest_size function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby String Scanner-class Similar Reads Ruby | StringScanner matched? function StringScanner#matched?() : matched?() is a StringScanner class method which checks whether the last match was successful. Syntax: StringScanner.matched?() Parameter: StringScanner values Return: true - if the last match was successful otherwise return false Example #1 : Ruby # Ruby code for StringSc 1 min read Ruby | StringScanner matched function StringScanner#matched() : matched() is a StringScanner class method which returns the last matched string. Syntax: StringScanner.matched() Parameter: StringScanner values Return: the last matched string. Example #1 : Ruby # Ruby code for StringScanner.matched() method # loading StringScanner require 1 min read Ruby | StringScanner match? function StringScanner#match?() : match?() is a StringScanner class method which checks whether the given pattern is matched from the current scan pointer. Syntax: StringScanner.match?() Parameter: StringScanner values Return: position - if pattern matches otherwise return false Example #1 : Ruby # Ruby code 1 min read Ruby | StringScanner rest_size function StringScanner#rest_size() : rest_size() is a StringScanner class method which returns the size of the bytes after the string position. Syntax: StringScanner.rest_size() Parameter: StringScanner values Return: the size of the bytes after the string position. Example #1 : Ruby # Ruby code for StringSc 1 min read Ruby | StringScanner pre_match function StringScanner#pre_match() : pre_match() is a StringScanner class method which returns the pre-match (in the regular expression sense) of the last scan. Syntax: StringScanner.pre_match() Parameter: StringScanner values Return: pre-match (in the regular expression sense) of the last scan Example #1 : 1 min read Ruby | StringScanner getch function StringScanner#getch() : getch() is a StringScanner class method which returns the byte of pointer on the StringScanner. Syntax: StringScanner.getch() Parameter: StringScanner values Return: the byte of pointer on the StringScanner. Example #1 : Ruby # Ruby code for StringScanner.getch() method # loa 1 min read Like