Pattern Matching Question

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?
lweinerAsked:
Who is Participating?
 
b2piCommented:
Often, asking a follow-up question is better than rejecting an answer.
0
 
b2piCommented:
$string  =~ s/^uid=([^,]*).*/$1/;

0
 
lweinerAuthor Commented:
This didn't work.  The script hangs.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
b2piCommented:
Not on that line it doesn't.  Best figure out what's going wrong
0
 
flivaudaCommented:
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
 
lweinerAuthor Commented:
This is all set, I am an idiot.
0
 
flivaudaCommented:
hook b2pi up with the points
0
 
ozoCommented:
     
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.