Solved

Regex Help

Posted on 2013-12-12
8
496 Views
Last Modified: 2013-12-12
I need help with a regex to match any one of these cases.

ATTENDEE;CN="Jason Johnson";CUTYPE=INDIVIDUAL;EMAIL="jason_johnson@sweet
 water.com";PARTSTAT=ACCEPTED:urn:uuid:2F00405F-6019-494D-BB8F-368758197A
 11
ATTENDEE;CN="Joe McNeely";CUTYPE=INDIVIDUAL;EMAIL="joe_mcneely@sweetwate
 r.com";PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE;SCHEDULE-STA
 TUS="1.2":urn:uuid:D6ABEECD-2352-4777-8567-369B6FD2FA43
ATTENDEE;CN="Mike Lentine";CUTYPE=INDIVIDUAL;EMAIL="mike_lentine@sweetwa
 ter.com";PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT;SCHEDULE-STATUS="2.0":ur
 n:uuid:9D2E81FD-97C4-44E0-951F-B67FF8FB8394
ATTENDEE;CN="Jason Johnson";CUTYPE=INDIVIDUAL;EMAIL="jason_johnson@sweet
 water.com";PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT:urn:uuid:2F00405F-6019
 -494D-BB8F-368758197A11
ATTENDEE;CN="John Hopkins";CUTYPE=INDIVIDUAL;EMAIL="john_hopkins@sweetwa
 ter.com";PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT:urn:uuid:AF78E76B-7447-4
 1E8-AC7E-51C27A9BEB5B

Open in new window


I'm close my problem is the spaces in the after the line breaks. I really need to eval it as a single uuid.. I am working on a calendar migration and I'm trying to find old UUID's and replace them. I attached the entire file just incase you want to see what I am working with.

(?s)urn:uuid:.{8}-.{4}-.{4}-.{4}-.{12}

Open in new window

Jason-Johnson-1.txt
0
Comment
Question by:JasonPJohnson
  • 4
  • 3
8 Comments
 
LVL 2

Author Comment

by:JasonPJohnson
ID: 39714930
I think I found 1 option...a bit ugly but hey it seems to work

urn:uuid:(?s).\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*
0
 
LVL 2

Author Comment

by:JasonPJohnson
ID: 39714937
this seems to work better.

(?s):u\s*r\s*n\s*:\s*u\s*u\s*i\s*d\s*:.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*-.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*.\s*
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 39714952
This would be a bit neater:
urn:uuid:(\S\s*){8}-(\S\s*){4}-(\S\s*){4}-(\S\s*){4}-(\S\s*){12}
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:Terry Woods
ID: 39714960
Can you strip out the spaces before applying the regex? That would be simpler.
0
 
LVL 2

Author Comment

by:JasonPJohnson
ID: 39714968
I tried to find and replace spaces but it wont import in to zimbra after words and I can't seem to figure out how to add them back in.
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 39714994
Combining your latest pattern, and mine, I get this, which seems to work ok:
u\s*r\s*n\s*:\s*u\s*u\s*i\s*d\s*:(\S\s*){8}-(\S\s*){4}-(\S\s*){4}-(\S\s*){4}-(\S\s*){12}
0
 
LVL 12

Expert Comment

by:stefan73
ID: 39715387
Split the tasks into steps:
$blob=<FILE>;
$blob =~ s/\n  //g;
@datasets=split("\n",$blob);

... then you can tackle each dataset separately and you don't end up with a regex which is hell to maintain.
0
 
LVL 2

Author Closing Comment

by:JasonPJohnson
ID: 39715396
Thanks perfect
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

726 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