类似于PHP的字符串解析 [英] PHP-like string parsing
问题描述
我正在编写各种微型控制台,并且试图弄清楚如何从链接中提取内容.例如,在PHP中,这是一个请求变量 所以:
I'm writing a mini-console of sorts and I'm trying to figure out how to extract things from a link. For example, in PHP this is a request variable so:
http://somelink.com/somephp.php?variable1=10&variable2=20
然后PHP找出url参数并将其分配给变量.
Then PHP figures out the url parameters and assigns them to a variable.
我该如何在Swift中解析这样的内容?
因此,给定我要使用的字符串:variable1 = 10和variable2 = 20等,有没有简单的方法可以做到这一点?我尝试使用Google搜索功能,但实际上并不知道我要搜索的内容.
So, given the string I'd want to take: variable1=10 and variable2=20 etc, is there a simple way to do this? I tried googling around but didn't really know what I was searching for.
我有一种非常骇人听闻的方法,但这并不是可扩展的.
I have a really horrible hacky way of doing this but it's not really extendable.