• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

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?
0
lweiner
Asked:
lweiner
  • 3
  • 2
  • 2
  • +1
1 Solution
 
b2piCommented:
$string  =~ s/^uid=([^,]*).*/$1/;

0
 
lweinerAuthor Commented:
This didn't work.  The script hangs.
0
 
b2piCommented:
Not on that line it doesn't.  Best figure out what's going wrong
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
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
 
b2piCommented:
Often, asking a follow-up question is better than rejecting an answer.
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.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now