Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parse keys to return portion of key with Regex

Posted on 2016-07-15
3
Medium Priority
?
122 Views
Last Modified: 2016-07-15
Hi! Looking for some regex help again...

I have an analytics tool which allows me to take Regex and pull out specific parts of a key. In my example below, I'm looking to pull out the values which are in the third slot of the delimiter ":" and I can use the $ to reference a value to return.

Example Keys
     manifest_acquisition_summersale
     gglp:paidsearch_nb_b2b:thisisthekeyword:thisistheoccassion
     gglp:paidsearch_nb:paid keyword:rewardsclub
     gglp:paidsearch_nb:gifts:sale
     gglp:paidsearch_things:keyword_phrase

Expected Result
     (no match expected)
     thisisthekeyword
     paid keyword
     gifts
     keyword_phrase

What I've tried:
This failed -->
 ^gglp:([^:]+)$ 

Open in new window

This failed -->
 ^gglp.*:([^:]+)$ 

Open in new window

and then I referenced $1  to return what was matched

Results Returned with what I've tried:
None -- all tries have failed. :( Help please!
0
Comment
3 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 1400 total points
ID: 41712662
Hi,

pls try to catch the second element (maybe $2)

(gglp:.*?:)([^:]+)

Open in new window

Regards
0
 
LVL 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 600 total points
ID: 41712705
Or stick with $1:
(?:gglp:.*?:)([^:]+)

Or, if "gglp:paidsearch" is a constant:
gglp:paidsearch.*?:([^:]+)

HTH,
Dan
0
 

Author Closing Comment

by:Elizabeth "Smalls" Eckels
ID: 41712834
Thanks @RGonzo and @Dan - both worked great!
0

Featured Post

[Video] Create a Disruption-Free Workspace

Open offices have their challenges. And Sometimes, it's even hard to work at work. It's time to reclaim your office and create a disruption-free workspace. With the MB 660, you can:

-Increase Concentration
-Improve well-being
-Boost Productivity

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
The burden of debt that average person carries today has not only increased, but it keeps on growing. It is quite common nowadays that people find it extremely difficult to make ends meet in the face of millions of competing priorities that they hav…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question