aardioٷ

¼ | עԱ
aardioٷ Ż

һЩģʽƥʾģʽƥ﷨⣩

: qqmmcc | ʱ: 2011-1-18 01:20| 鿴: 5951| : 4|ģʽ

qqmmcc 2011-1-18 01:20 ༭

ժ¼̳һЩģʽƥʣ԰˵

1.
io.open()
str="abcabc123"
\\(abc)ƥabc,(\1 õһabc ,\d+ƥ123,ȥ+ֻƥһ)
paten="(abc)(\1\d+)"
var m,m2=string.match(str,paten)
io.print(m,m2)

paten1="(abc)"
paten2="(\d+)"
paten3="\1"

m=string.match(str,paten1)
io.print(m)
m=string.match(str,paten2)
io.print(m)
m,m2=string.match(str,paten1++paten2)
io.print(m,m2)


ģʽͿñʾ,++


2.
ַڲո
io.open()
var str = string.replace("a b c d","\s","");
io.print(str); //abcd


3.
ǰֺ.ȥаѺ-Winampȥ

io.open()
str="714. Ыֶ - Hurricane 2000 - Winamp"


\\^\d+\.ʾַֿʼ.ȥ(.*?)̰ƥ䲶κַ()ƥųȡ
str=string.match (str, "^\d+\.(.*?) - Winamp" )
io.print(str)


4.
%Գƥ Ҫڵ''

io.open()
str = 'a = 1a(b)cd2 ' //ַ˫Ӧڵ

//'%12'ʾ1ʼ2βַƥ
str2 = string.match(str, '%12')
io.print(str2); //ʾ 1a(b)cd2

//ֽڣҪд %<><>
str = 'a = a(b)cd '
str2 = string.match(str, '%<><>')
io.print(str2); //ʾ a(b)cd


5.
ƥ

io.open();
str1="䣺abcdefg+1@gmail.com վgoogle"
str2="䣺abcde_fg@gmail.com վgoogle"
str3="䣺abcdefg.@gmail.com վgoogle"
str4="䣺abcdef-g.@gmail.com վgoogle"

tab = {}

table.push(tab,str1,str2,str3,str4)

/*
email=string.match(str,"\w+[\w\_\p\.]+\w*?@\w+[\w\-\.]+\w{2,}")


\w+ ƥĸ1ε
[\w\_\p\.]+ ƥĸ » Բ֮һ
\w*? ƥ@֮ǰַ ̰ƥ

\w+[\w\-\.]+\w{2,} ƥ

*/

for m,m2,m3 in string.gmatch(table.tostring(tab),"\w+[\w\_\p\.]+@\w+[\w\-\.]+\w{2,}") {
    io.print(m)
}
//io.print(email)
execute("pause");
io.close();


6.
io.open()

a="123456789
987654321"


\\ \N* ʾз
m = string.match(a,"\N*") //ȼ m = string.match(a,"[^\n]*")
io.print( m )  //ʾ123456789



7.
ģʽƥ,ʹ"<@@ԴСд@>"ָһԴСдıȽ
io.open();//򿪿̨

html =
"<sPan>A</span>"

//ʹ%﷨ƥԵHTML(ԴСдƥ)
str = string.replace(html,"%<\<[sS][pP][aA][nN][^>]*><\</[sS][pP][aA][nN]\>>?","滻")
io.print(
"滻" ,str );

//ЩԴСдıȽϣƥ䣬ûпǶԳǶ׵
//ڴƥУ@@ָһԴСдıȽ
str = string.replace(html,"<@@<span@>.*\>(.+?)<@@</span>@>","<div>\1</div>")
io.print(
"滻" ,str );

execute("pause") //
io.close();//رտ̨


8.Ӧã֧

io.open();//򿪿̨

str =
'<DIV class=Page_s_box><DIV class="pags F_wide">225020,ÿҳ5001/451ҳ</DIV><UL class=Pag_num><LI class=now>'

io.print(string.match(str,
"(\d*),ÿҳ500(\d*)/(\d*)ҳ"))//ʾ 225020 1 454


9.ڴƥУ+*Ǽ̰ƥ䣬һ̰.+ֱӵַβ

str = "<html><body><center><font color=#21B929>aardio̵</font></body></html>"

// "[^\>]+\>" ˼Ӧз>ַ>ַ
str2 = string.match(str,"<\<[^\>]+\>>")

io.open()
io.print(str2)//ʾ<html>

inerHtml = "<html><body><center><font color=#21B929>aardio̵</font></body></html>"

io.open()
while(inerHtml){
    tag,inerHtml = string.match(inerHtml,
"\<(\w+)(.+)\</\1\>")
    io.print( tag,inerHtml );
   
}



10.ϣƥ䵽һҳǰ<a ƥ

io.open();//򿪿̨

html =
/*
<div class="pg"><strong>1</strong><a href="http://bbs.aardio.com/thread-382-2-1.html">2</a><a href="http://bbs.aardio.com/thread-382-3-1.html">3</a><a href="http://bbs.aardio.com/thread-382-4-1.html">4</a><a href="http://bbs.aardio.com/thread-382-5-1.html">5</a>
<a href="http://bbs.aardio.com/thread-382-2-1.html" class="nxt">һҳ</a></div>
*/


str = string.match( html,
"\<a href\s*\=[^<]+?һҳ" )
io.print(str)

execute("pause") //
io.close();//رտ̨



11.
/*strепոҪs1=ƻ s2= s3=0.50 ո   Ϊȫǵ*/

io.open();//򿪿̨


var str = //ƻ 0.50

//÷ȫǵģֱӣʾ

p="(<:>+)\s+(:)\s+([\d\.]+)"
s1,s2,s3 = string.match(str,p);
io.print(s1,s2,s3)

execute("pause") //
io.close();//رտ̨




̳ʣиôǿúѧϰҪ֪ʶڴллʼѣҲлѧϰĵõѣֻΪ˼ἰ֪ʶôԼʵп֪ʶӡͬϴ˵һ仰ʵ֪ʶˮΣһ֮ÿѧϰͬԼʵѧϰͺˣϰȴǷdzҪġ

ak47xxx 2011-1-18 22:48:10

ˮӡԺCC

ˮӡԺCC
nvt303 2011-1-19 18:17:57

ǺţԺҡ

ǺţԺҡ
51ak 2011-1-19 23:21:14

лǺš

лǺš
2017-2-18 22:53:11

ֻ|δϽûתرվ|վ|aardio.com|aardioٷ ( ICP09012014 )

GMT+8, 2017-11-23 20:42 , Processed in 0.140625 second(s), 20 queries , WinCache On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

ٻظ ض б