?
Solved

parse a file

Posted on 2008-02-04
6
Medium Priority
?
231 Views
Last Modified: 2012-06-22
From the following file I need to get everything after Members but just beforr crackets for example the output for the following input will be. So in every line lookfor Members  and get everything just before comma like this

cmandali
legarcia
mrottman
nfluhman
TestMINA

______________________________________________________________
2/4/2008 12:53:55 PM   Version: 8.1.0 (Build 8.1.000.149)
2/4/2008 12:53:55 PM   Project Source: 1-DEV (SMFIMDMSI01)
2/4/2008 12:53:55 PM   Login: administrator
2/4/2008 12:53:55 PM   Executing task(s)...
2/4/2008 12:53:55 PM   Members = cmandali (Chandrashekar Mandali), legarcia (Leonardo Garcia), mrottman (Matthew Rottman), nfluhman (Nathan Fluhman)
2/4/2008 12:53:55 PM   Members = TestMINA (TestMINA)
2/4/2008 12:53:55 PM   Task(s) execution completed successfully.
0
Comment
Question by:anshuma
  • 3
  • 3
6 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 20819129
perl -lne '($_)=/Members(.*)/;print for /(\w+)\s*\(/'
0
 

Author Comment

by:anshuma
ID: 20819308
Hello Ozo,

Instead of running this command can i get this in a file form.

thanks
-anshu
0
 
LVL 85

Expert Comment

by:ozo
ID: 20819490
#!/usr/bin/perl
$\=$/;
while( <> ){
  ($_)=/Members(.*)/;  print for /(\w+)\s*\(/;
}
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 

Author Comment

by:anshuma
ID: 20819735
Hello Ozo,

this is not working as expected. it's only printing the first user for every line, but that line might have more users after commas. Can you try this with the input I gave.

thanks
-anshu
0
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 20819762
sorry, I left out the /g
  print for /(\w+)\s*\(/g;
0
 

Author Closing Comment

by:anshuma
ID: 31428234
Hey Ozo,

You are amazing. Thanks alot

-anshu
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

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

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…
Six Sigma Control Plans
Suggested Courses

592 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