Ruby | StringScanner search_full function

StringScanner#search_full() : search_full() is a StringScanner method which scans the string until the pattern is matched.

Syntax: StringScanner.search_full()

Parameter: StringScanner values
pattern
advance_pointer
return_pointer

Return: matched string if return_string_p is true otherwise return the number of bytes advanced

Example #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for StringScanner.search_full() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("Mon Sep 12 2018 14:39")
   
# search_full() method
c.search_full(/\w+/, 2, 3)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"
  
# search_full() method
c.search_full(/\s+/, 4, 8)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"

chevron_right


Output :

String Scanner result of c.search_full() form : 3

String Scanner result of c.search_full() form : 4

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby code for StringScanner.search_full() method
  
# loading StringScanner
require 'strscan'
  
# declaring StringScanner 
c = StringScanner.new("h ello geeks")
   
# search_full() method
c.search_full(/\w+/, 2, 3)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"
  
 search_full() method
c.search_full(/\s+/, 4, 8)
  
puts "String Scanner result of c.search_full() form : #{c.pos()}\n\n"

chevron_right


Output :

String Scanner result of c.search_full() form : 1

String Scanner result of c.search_full() form : 2



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.