自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

迅速掌握Ruby轉(zhuǎn)義字符

開發(fā) 開發(fā)工具
我們在這里為大家詳細介紹了有關(guān)Ruby轉(zhuǎn)義字符的相關(guān)用法,希望大家可以通過本文介紹的內(nèi)容深入了解Ruby語言的相關(guān)知識。

Ruby轉(zhuǎn)義字符對于一個初學(xué)Ruby語言來說是一個比較陌生的用法。在下面這篇文章中我們將會學(xué)到一些關(guān)于Ruby轉(zhuǎn)義字符的相關(guān)用法。#t#

Ruby轉(zhuǎn)義字符代碼示例:

 

 

  1. #! /usr/local/bin/ruby  
  2. # Author: xlzhu  
  3. # date: 2009-12-08  
  4. # Summary: encode string.  
  5.  
  6. class IEncoder  
  7. def initialize  
  8. end  
  9.  
  10. # Execute the given file using 
    the associate app  
  11. def run(orgStr)  
  12. str = orgStr 
  13. strstr = str.gsub('<', '&lt;')  
  14. strstr = str.gsub('>', '&gt;')  
  15. strstr = str.gsub(/['"]/, '&quot;')  
  16. strstr = str.lstrip #去掉前后空格  
  17. strstr = str.delete("\n\r") #去掉換行符  
  18. strstr = str.delete(" ")#去掉tab  
  19. puts str  
  20. end  
  21.  
  22. end 


iencoder = IEncoder.new
txt = IO.read("renderers.xml")
puts txt
iencoder.run(txt)

以上就是Ruby轉(zhuǎn)義字符的相關(guān)使用方法介紹。

責(zé)任編輯:曹凱 來源: 新浪博客
相關(guān)推薦

2009-12-16 10:57:16

Ruby文件鎖

2009-12-14 17:23:31

2009-12-14 16:35:28

Ruby文件行數(shù)計算

2009-12-18 14:19:45

Ruby on Rai

2009-12-10 14:18:22

PHP導(dǎo)出Word文檔

2009-12-14 18:23:38

Ruby DSL測試

2009-10-29 13:38:05

VB.NET Shar

2010-01-11 14:28:14

VB.NET操作Exc

2010-01-12 10:19:02

VB.NET操作GDI

2009-12-11 16:39:08

PHP引號轉(zhuǎn)義

2009-12-04 14:23:33

PHP JSON加密函

2009-12-17 14:36:57

Ruby on Rai

2009-06-28 22:56:00

虛擬化桌面虛擬化問題

2010-01-07 11:07:20

VB.NET讀取INI

2009-08-17 17:04:29

C#轉(zhuǎn)義字符

2010-07-14 15:32:21

Perl轉(zhuǎn)義字符

2009-12-16 17:31:30

Ruby on Rai

2010-01-08 18:10:44

VB.NET實現(xiàn)任務(wù)欄

2009-12-14 13:19:07

Ruby字符串

2010-05-24 09:57:08

點贊
收藏

51CTO技術(shù)棧公眾號