迅速掌握Ruby转义字符
Ruby转义字符对于一个初学Ruby语言来说是一个比较陌生的用法。在下面这篇文章中我们将会学到一些关于Ruby转义字符的相关用法。
Ruby转义字符代码示例:
- #! /usr/local/bin/ruby
- # Author: xlzhu
- # date: 2009-12-08
- # Summary: encode string.
- class IEncoder
- def initialize
- end
- # Execute the given file using
the associate app - def run(orgStr)
- str = orgStr
- strstr = str.gsub('<', '<')
- strstr = str.gsub('>', '>')
- strstr = str.gsub(/['"]/, '"')
- strstr = str.lstrip #去掉前后空格
- strstr = str.delete("\n\r") #去掉换行符
- strstr = str.delete(" ")#去掉tab
- puts str
- end
- end
相关推荐
IT之家 2020-03-11
graseed 2020-10-28
zbkyumlei 2020-10-12
SXIAOYI 2020-09-16
jinhao 2020-09-07
impress 2020-08-26
liuqipao 2020-07-07
淡风wisdon大大 2020-06-06
yoohsummer 2020-06-01
chenjia00 2020-05-29
baike 2020-05-19
扭来不叫牛奶 2020-05-08
hxmilyy 2020-05-11
黎豆子 2020-05-07
xiongweiwei00 2020-04-29
Cypress 2020-04-25
冰蝶 2020-04-20