lua——string之string.gsub
string.gsub用法:
下面是一些例子:
x = string.gsub("hello world", "(%w+)", "%1 %1")
--> x="hello hello world world" x = string.gsub("hello world", "%w+", "%0 %0", 1)
--> x="hello hello world" x = string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
--> x="world hello Lua from" x = string.gsub("home = $HOME, user = $USER", "%$(%w+)", os.getenv)
--> x="home = /home/roberto, user = roberto" x = string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
return loadstring(s)()
end)
--> x="4+5 = 9" local t = {name="lua", version="5.1"}
x = string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
--> x="lua-5.1.tar.gz"
lua——string之string.gsub的更多相关文章
- Lua的string和string库总结
Lua有7种数据类型,分别是nil.boolean.number.string.table.function.userdata.这里我总结一下Lua的string类型和string库,复习一下,以便加 ...
- lua字符串处理(string库用法)
原文地址http://www.freecls.com/a/2712/f lua的string库是用来处理字符串的,基础函数如下 string.byte(s [, i [, j]]) string.by ...
- Lua 中的string库(字符串函数库)总结
(字符串函数库)总结 投稿:junjie 字体:[增加 减小] 类型:转载 时间:2014-11-20我要评论 这篇文章主要介绍了Lua中的string库(字符串函数库)总结,本文讲解了string库 ...
- lua语言:string
转载请注明来源:https://www.cnblogs.com/hookjc/ 字符串库函数string.len(s) 返回字符串s的长度:string.rep(s, n) ...
- lua 中string字符串的使用(string.len, string.char)
table.keys 返回指定表格中的全部键. 格式: keys = table.keys(表格对象) 使用方法演示样例: local t = {a = 1, b = 2, c = 3} local ...
- [C#] string 与 String,大 S 与小 S 之间没有什么不可言说的秘密
string 与 String,大 S 与小 S 之间没有什么不可言说的秘密 目录 小写 string 与大写 String 声明与初始化 string string 的不可变性 正则 string ...
- java.lang.String.getBytes(String charsetName)方法实例
java.lang.String.getBytes(String charsetName) 方法编码将此String使用指定的字符集的字节序列,并将结果存储到一个新的字节数组. 声明 以下是java. ...
- C#,int转成string,string转成int
转载:http://www.cnblogs.com/xshy3412/archive/2007/08/29/874362.html 1,int转成string用toString 或者Convert.t ...
- C#中对string与string[]的初步操作
开篇之作,简单的对string与string[]进行初步操作,入门篇也,不多说,直接上代码. using System; using System.Collections.Generic; using ...
随机推荐
- leetcode185 Department Top Three Salaries
Employee表存储员工姓名.员工所在公寓.员工工资 Department表存储公寓id 评选出各个公寓的工资前三名的员工. 遇到的问题如下: limit,in等语句不能用在嵌套select语句中, ...
- Quartz.net官方开发指南[转]
http://www.cnblogs.com/shanyou/category/102991.html
- python练习笔记——模拟双色球随机输出情况
编写Python函数:完成一个双色球彩票的模拟生成过程, 其中前六个为蓝色球,数字范围1-33,不可重复.最后一个为红色球 1-16. 使用random完成,最后将7个数进行排列放到列表中 # 引入r ...
- Template Method - 模板方法模式
1.概述 在面向对象开发过程中,通常我们会遇到这样的一个问题:我们知道一个算法所需的关键步骤,并确定了这些步骤的执行顺序.但是某些步骤的具体实现是未知的,或者说某些步骤的实现与具体的环境相关.例子1: ...
- Objective-C学习笔记(十八)——对象方法和类方法的声明,定义及调用
在程序设计中,函数的使用无疑大大简化了代码的编写.提高代码执行的效率.降低反复代码. 所以如今我们来具体研究一下方法. 本样例还是以People类为例. (一)代码一: (1)先在People.h中声 ...
- C# 查看动态库的方法
使用Vs自带工具:开始菜单-->Microsoft Visual Studio 2010--> Visual Studio Tools-->Visual Studio 命令提示符 输 ...
- Unityclient框架笔记二(组件实体开发模式的思考)
Unity的Entity-Component-System实现的很美丽,很灵活.许多文章也对这样的组件实体的开发模式倍加推崇.由于它契合这么一条规则:优先使用组合而不是继承. 可是实际开发过程中,限制 ...
- VLOG丨树莓派Raspberry Pi 3安装PLEX并挂载USB硬盘打造最牛的微型家庭影音服务器2018
视频介绍 树莓派3安装目前最流行的PLEX服务器,实现既能最大限度降低功耗,也能随时随地观看分享影片. 一.在树莓派下安装PLEX媒体服务器 1.在终端,将你的树莓派更新至最新 sudo apt up ...
- node 服务器开发必备神器 —— nodemon
nodemon 官方网站:http://nodemon.io/ github地址:https://github.com/remy/nodemon/ 简介:Nodemon 是一款非常实用的工具,用来监控 ...
- kafka linux 启动脚本 sample
#!/bin/sh # # chkconfig: 345 99 01 # description: Kafka # # File : Kafka # # Description: Starts and ...