Solved

Pattern Matching Question

Posted on 1998-12-10
8
132 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Rename file based on contents in the file? 3 80
Need to install DBD::MySQL on a MAC without a local MySQL server for Perl 4 48
syslog unix file 20 68
PERL - Find newest folder 12 118
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now