Solved

Pattern Matching Question

Posted on 1998-12-10
8
135 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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 50 total points
ID: 1206862
Often, asking a follow-up question is better than rejecting an answer.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1206863
     
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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

688 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