[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Pattern Matching Question

Posted on 1998-12-10
8
Medium Priority
?
138 Views
Last Modified: 2010-05-18
I have a string that I want to strip out everything after the first comma - and then I want to only keep the value of uid=, for example:

$string = "uid=fred,ou=BigGuys,ou=People,ou=Airius.com";
I want the value of $string = "fred"

How can I do this?
0
Comment
Question by:lweiner
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 5

Expert Comment

by:b2pi
ID: 1206856
$string  =~ s/^uid=([^,]*).*/$1/;

0
 

Author Comment

by:lweiner
ID: 1206857
This didn't work.  The script hangs.
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1206858
Not on that line it doesn't.  Best figure out what's going wrong
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 1

Expert Comment

by:flivauda
ID: 1206859
What error do you get?  The code that b2pi gave you is correct if you copy it exactly it will work, you must have a problem somewhere else in your code
0
 

Author Comment

by:lweiner
ID: 1206860
This is all set, I am an idiot.
0
 
LVL 1

Expert Comment

by:flivauda
ID: 1206861
hook b2pi up with the points
0
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1206862
Often, asking a follow-up question is better than rejecting an answer.
0
 
LVL 85

Expert Comment

by:ozo
ID: 1206863
     
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

834 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