从URL获取参数,在查询字符串中获取子字符串并将其存储在表中

编程入门 行业动态 更新时间:2024-10-22 17:27:34
本文介绍了从URL获取参数,在查询字符串中获取子字符串并将其存储在表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想获取URL中某些参数的值,我知道这个主意,但不知道如何获取它们.

I want to get the values of some parameters in a URL, I know the idea but I don't know how to do get them.

我有一个URL字符串:

I have an string that is an URL:

local url="fbconnect://success?to[0]=213322147507203&to[1]=223321147507202&request=524210977333164"

我想检测子字符串"to ["并获取数字293321147507203、293321147507202并将它们存储在表中.

I want to detect the sub-strings "to[" and get the numbers 293321147507203,293321147507202 and store them in a table.

我知道该过程是检测子字符串to [,然后获取为3个字符的子字符串(或6不确定是否从"to ["开头开始计数,然后获取数字,始终为15位数字.

I know the process is detect the sub-string to[ and then get the sub-string that is 3 character (or 6 not sure if it counts from the beginning of "to[" and then get the number, always is a 15 digit number.

推荐答案

local url="fbconnect://success?to[0]=213322147507203&to[1]=223321147507202&request=524210977333164" local some_table = {} for i, v in url:gmatch'to%[(%d+)]=(%d+)' do some_table[tonumber(i)] = v -- store value as string end print(some_table[0], some_table[1]) --> 213322147507203 223321147507202

更多推荐

从URL获取参数,在查询字符串中获取子字符串并将其存储在表中

本文发布于:2023-10-27 00:03:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531732.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   参数   并将其   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!