Solved

Pattern Matching Question

Posted on 1998-12-10
8
133 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTP Error 502.2 - Bad Gateway 3 217
stftime format 4 56
How to get all the API from website? 11 91
Vb script to unzip a files and rename the files 5 92
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 …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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