Warm tip: This article is reproduced from serverfault.com, please click

coldfusion-通过使用正则表达式从网址中提取值

(coldfusion - extract value from the url by using a regex)

发布于 2020-12-02 23:50:36

我有这个字符串值

var x = '/index.cfm?act=page1.showdata';

要提取 page1

如果我必须简单地使用它,我会使用contains来查找它并使它起作用,但是我真的很想使用正则表达式来查找该值并将其放入变量中,

使用冷熔

Questioner
Jan
Viewed
11
Adrian J. Moreno 2020-12-03 08:22:37

无需正则表达式。范围中的每个查询字符串参数均可用url它们都已经变了。

<cfdump var="#url#">

这将转储一个以键为参数的结构。

因此CF变量url.act的值(字符串)为page1.showdata

你还需要什么呢?