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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
b2piConnect With a Mentor Commented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
All Courses

From novice to tech pro — start learning today.