Skip to content

Latest commit

 

History

History

0x06-regular_expressions

img

Regular expressions

meme

Intro

Regex is a powerful tool for text processing, and can be used in a variety of applications, including search and replace operations, data validation, and pattern matching. Through this project we will learn the basics of regex syntax, how to write simple and complex regex patterns, and how to use regex in practical examples. The project is intended for those who have limited or no experience with regex and wish to learn more about this versatile tool, or those who have been using it for a while and would like to refresh their minds about some of the concepts

Background context

For this project, you have to build your regular expression using Oniguruma, a regular expression library that which is used by Ruby by default. Note that other regular expression libraries sometimes have different properties.

Because the focus of this exercise is to play with regular expressions (regex), here is the Ruby code that you should use, just replace the regexp part, meaning the code in between the //

itsfoss@itsfoss$ cat example.rb
#!/usr/bin/env ruby
puts ARGV[0].scan(/127.0.0.[0-9]/).join
itsfoss@itsfoss$
itsfoss@itsfoss$ ./example.rb 127.0.0.2
127.0.0.2
itfoss@itsfoss$ ./example.rb 127.0.0.1
127.0.0.1
itsfoss@itsfoss$ ./example.rb 127.0.0.a

Resources

Read or Watch:

  1. Regular expressions - basics
  2. Regular expressions - advanced
  3. Rubular is your best friend
  4. Use a regular expression against a problem: now you have two problems
  5. Learn Regexs with simple interactive exercises
  6. Regex101
  7. Youtube
  8. Google

Requirements

General

  • Allowed editors vi, vim, emacs
  • All your files will be interpreted on Ubuntu 20.04 LTS
  • All your files should end with a new line
  • A README.md file, at the root of the folder of the project, is mandatory
  • All your Bash script files must be executable
  • The first line of all your Bash scripts should be exactly #!/usr/bin/env ruby
  • All your regex must be built for the Oniguruma library

Quiz

Quizes