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

extract value from the url by using a regex

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

I have this string value

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

want to extract page1

if i had to use it as simple, i am use contains to find it and make it work, but i really want to use regex to find that value and put it into a variable,

using coldfusion

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

No need for regex. Every query string parameter is available in the url scope. They're all already variables.

<cfdump var="#url#">

This dumps a struct whose keys are the parameters.

So the CF variable url.act has a value (string) of page1.showdata.

What else do you need than that?