• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

RegEx Help

Explorer ,
Apr 20, 2011 Apr 20, 2011

Copy link to clipboard

Copied

Hello,

I have the following URL, http://acme.com/jdoe?CID=kno00000000123:561342

and I need to pull the "jdoe" and the CID values ("kno00000000123:561342") separately.

I can pull the "jdoe" part with this expression: ^(.+) but I can't figure out how to combine it to also include the "kno00000000123:561342" portion.

I've tried this, ^(.+)/^CID=(.+), but it doesn't work.

Can someone shed some light?

TIA

TOPICS
Advanced techniques

Views

512

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 20, 2011 Apr 20, 2011

Copy link to clipboard

Copied

List functions might be easier.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 20, 2011 Apr 20, 2011

Copy link to clipboard

Copied

I need RegEx since this is an ISAPI filter on IIS

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 21, 2011 Apr 21, 2011

Copy link to clipboard

Copied

Using ^http://acme.com/([^/]+)\?CID=(.*)$ as your pattern should work for matching what you need (assuming there are no other pattern requirements beyond what you're giving us with your sample URL, like the CID not necessarily being the first param, there maybe being other params, etc).  If you use the "returnsubexpressions" switch on reFind() you can then use mid() to pull out the specific values.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 14, 2011 Jul 14, 2011

Copy link to clipboard

Copied

I'm a little rusty on my Regular expressions, but I think you meant to use a [^?] after the "acme.com/" since I would expect that you are trying to retrieve everything until you hit the "?"

e.g.:

^http://acme.com/([^?]+)\?CID=(.*)$

Balance - you said something about using the RegEx for rewrites in IIS.  will you have access to CF or are you using the regular expresions inside of a IIS filter?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2011 Jul 15, 2011

Copy link to clipboard

Copied

LATEST

Good spot: you're dead right about the correction to my regex.  I was not paying attention to what I was doing.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation