Lua 模式 - 如何删除字符串中不需要的字符串

发布于 2024-11-18 11:58:05 字数 5260 浏览 1 评论 0原文

我收到了如下所示的一堆行

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ペ泪落弦音 2024-11-25 11:58:05

尝试 s=s:gsub("(.-)","%1")

Try s=s:gsub("<a.->(.-)</a>","%1").

゛清羽墨安 2024-11-25 11:58:05

这会删除括号中的所有内容:
s=s:gsub("%b>>", "")

This gets rid of everything in brackets:
s=s:gsub("%b<>", "")

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文