Solved

Pattern Matching Question

Posted on 1998-12-10
8
131 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

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 …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

18 Experts available now in Live!

Get 1:1 Help Now