Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




RUBY - REGEX


Say for example, you have saved a long paragraph in a file. And you want to search if a particular block of String is present in it or not.


Or maybe you have stored some data in a Collection(Say, List, Set e.t.c.).


Well! We have seen some ways of searching the data. But now, let us see a better one.


And as said, Regex provides a better searching experience with some pattern.


Let us see them below:


Note : Don't get panicked by the below Functions. We will provide a detailed explanation for the below Functions, once we start learning the Regex patterns.
  1. scan()

    scan() Method returns the searched results as an Array.

  2. match()

    match() Method returns a Match Data if the pattern is matched.

  3. split()

    split() Method returns the searched results as an Array, splitted by the search pattern.

  4. sub()

    The sub() Method is used to replace the first occurrence of the searched pattern with a given text.

  5. gsub()

    The gsub() Method is used to replace the searched pattern with a given text.

In the next tutorial, let us look Regex Patterns and see how the above Functions works.