Leet string conversion program

【Overview】

1. Conclusion </ b>

2. What is the Leet character? </ B>

3. How to code </ b>

4. Development environment </ b>

  1. Conclusion

Use the gsub! </ B> method


2. What is the Leet character

It mainly refers to the notation of the alphabet used on the Internet. For example, "HELLO" would be "H3LL5". It will be in the form of applying numbers and letters similar to the alphabet. Below is a table of specific examples, but of course there are A to Z, and there are many ways to express them.

letter Numbers
A 4
B 13
C [
D )
E 3

. . .

letter Numbers
Z 2

Referenced URL: Wikipedia: Leet Symbol Table

  1. How to code

variable= gets.chomp
variable.gsub!(/Character string before conversion/,'Converted string')
puts variable

#ex)
#leet_str = gets.chomp
#leet_str.gsub!(/Z/,'2')
#puts leet_str
#"Z"When you enter"2"Converted to

There are other ways, but I used gsub !.

Referenced URL: [Introduction to Ruby] Summary of character string replacement methods (gsub sub regex)

  1. Development environment

Mac catalina 10.15.4 Vscode Ruby 2.6.5 Rails 6.0.3.3