lua 9 parttern 字符极其简要的介绍

摘自:https://www.lua.org/pil/20.2.html

所有的字符和含义包括:

. all characters
%a letters
%c control characters
%d digits
%l lower case letters
%p punctuation characters
%s space characters
%u upper case letters
%w alphanumeric characters
%x hexadecimal digits
%z the character with representation 0

它们的大写,表示小写含义的补集。比如 %a 表示所有的字母,%A 表示所有的非字母。

魔法字符(magic characters ->_->

( ) . % + - * ? [ ^ $

+表示重复可以不止一次,

*和+类似,但是接受零次

-和+类似,接受零次,匹配最短的  

在字符替换、匹配、查找中,都可以参考https://www.lua.org/pil/20.2.html

原文地址:https://www.cnblogs.com/alexYuin/p/9950685.html