Advertisement

06.09.2006 at 07:45AM PDT, ID: 21880892
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Regex to extract a particular value from within a delimited string

Asked by charvett in Perl Programming Language

Tags: , , , ,

Hi everyone, I'm currently working on a way to parse out a web server log file and I've managed to put together the regular expression that pulls each field that is delimited by space.

I have however realized it would be much more helpful if I could pull out a single value with a 'key-value pair' in the cookie field.

Here's the current expression I'm using:

(?<ip>\S+)\s+(?<xrfc931>\S+)\s+(?<username>\S+)\s+\[(?<date>\S+)\:+(?<time>\S+\:+\S+\:+\S+)\s+(?<xTimezone>[^\]]*)]\s+"(?<xhttpmethod>\S+)\s+(?:(?<uristem>\S+?)\?(?<uristemquery>\S+)|(?<uristem>\S+))\s+(?<xhttpprotocol>\S+)"\s+(?<viewstatus>\S+)\s+(?<xbytes>\S+)\s+\"(?<referer>[^\"]*)\"\s+\"(?<useragent>[^\"]*)\"(?:\s+\"(?<cookie>[^\"]*)\"|\s)

To parse out a line within a log file such as:

205.188.116.5 - - [25/May/2006:03:00:05 -0700] "GET /main.do HTTP/1.1" 302 - "-" "Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.0; .NET CLR 1.1.4322; Hotbar 4.6.1)" "Beacon=hsareg.59808951.jdw0725590001.hsa0.1148551020.RemoveMe; __utma=175376801.1874071127.1148452243.1148452243.1148551027.2; __utmz=175376801.1148452243.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); ctc=on%5F3; cpa_ver3=249%2C898%2C2826%2C71%2C-1%2C1148551098%3B247%2C892%2C2817%2C130431%2C-1%2C1148551188%3B242%2C897%2C2834%2C130541%2C-1%2C1148452462%3B246%2C890%2C2816%2C130431%2C-1%2C1148551123; bht=24-13-0-0-0%3A45-18-0-0-0; id=78773248; fci=891-0-2-1148452463-2%3A892-0-2-1148551188-2; fcc=; __utmb=175376801; __utmc=175376801; JSESSIONID=DFEA5BD2A779EE45CC58145BD8D20D9F"

Instead of parsing out the entire cookie value, I'm hoping to define cookie as only the value for JSESSIONID. So in the above example cookie would be only '
DFEA5BD2A779EE45CC58145BD8D20D9F'

Is this possible using a regular expression?

Thanks!Start Free Trial
 
 
[+][-]06.09.2006 at 09:16AM PDT, ID: 16871645

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: delimiter, extract, regex, within, utmcsr
Sign Up Now!
Solution Provided By: mccarl
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.08.2006 at 08:13PM PDT, ID: 17066809

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.10.2006 at 06:52AM PDT, ID: 17072880

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.19.2006 at 04:32AM PDT, ID: 17137372

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]07.23.2006 at 02:42PM PDT, ID: 17164277

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32