Lua 模式 - 如何删除字符串中不需要的字符串
我收到了如下所示的一堆行
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
您在每一行中都看到,我收到了一个由 HTML 标签包围的值,如下所述。
<a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a>
我想真正摆脱这些 html 标签,并希望用隐藏在这些 html 标签内的真实值替换所有该值,即 AAUUM_ARRTC_0211_TBT
所以在处理后我需要上面的数据应该变成这样这。
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
我需要使用 Lua 模式来完成这个任务。有人可以帮助我并分享他们的经验吗?
谢谢
I am receiving bunch of rows like below
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 <a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a> 18.03 18.03 EUR 1.14977 20.73 20.73
You see in every row, I am receiving a value surrounded by HTML tags as mentioned below.
<a href="/cgi-bin/recon_detail?rectent=AAUUM&benificary=ARRTC&period=2011/02&svctype=Voice">AAUUM_ARRTC_0211_TBT</a>
I want to actually get rid of these html tags and want to replace all that value with the real value which is hidden inside these html tags, which is AAUUM_ARRTC_0211_TBT
So after processing I need the above data should become like this.
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
2011/02 ARRTC AAUUMCO ZZITNWMOBILE COMMUNICATIONS CENTER ARRTC-AAUUM-TBT-2011-02 0.00 AAUUM_ARRTC_0211_TBT 18.03 18.03 EUR 1.14977 20.73 20.73
I need to achieve this task using Lua pattern. can anybody help me and share their experience.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
s=s:gsub("(.-)","%1")
。Try
s=s:gsub("<a.->(.-)</a>","%1")
.这会删除括号中的所有内容:
s=s:gsub("%b>>", "")
This gets rid of everything in brackets:
s=s:gsub("%b<>", "")