Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Regular expression help

by 2teez (Priest)
on Mar 12, 2013 at 09:27 UTC ( #1022951=note: print w/replies, xml ) Need Help??


in reply to Re^2: Regular expression help
in thread Regular expression help

But I need it in regular expression..
So, McA solution is using what? Please show what you have done on your own.
The result you are getting and what is expected.
Thanks

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^4: Regular expression help
by ghosh123 (Monk) on Mar 12, 2013 at 09:45 UTC

    Well the problem is a bit more complicated. The solution McA has given certainly works.

    Lets say in the loop, I first grep it for a particular user say, stephen by the following expression ,although the later part of this expression needs to be corrected for the server name and etc

    if(/^\s+stephen(.*)/)

    And , now for the subsequent iteration, I want to grep all the user names and servername,version name for other users who are not stephen. That is becoming a problem to uniquely identify the lines for which the user name is not known. So using split is a problem. Can't I have a regular expression of the following pattern :
    $line =~ /^\s+(any user but stephen) (machine name) (version)(server)(date time )/
    Hope I could explain the problem.
    Thanks.

      while(<DATA>){ next if /^\s*stephen\s/; if (~m/^(\w+?)\s+(\w+?)\s+\((\w+?)\)\s+\((\w+?)\),\s+.+$/){ print "user: $1 version: $3 server: $4"; } }

      (More complicated and less elegant that the use of split in any case IMHO...)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022951]
help
Chatterbox?
[ambrus]: Also, I was wrong, apparently you have to support both periodic and one-shot timers in an AnyEvent backend
[Corion]: ambrus: That looks deceptively simple, but maybe that's simply all that's needed. Which would be great! I hope I get to test it tomorrow, thanks!!
[choroba]: Hm, unrelated question.
[ambrus]: I added a timer implementation to ambrus's scratchpad as well, again the whole thing is completely untested and probably has more bugs than lines
[choroba]: Anyone using anything to validate json contents of a REST service?
[moritz]: choroba in python I use jsonschema
[moritz]: I'm sure there's a Perl implementation of it too
[choroba]: it seems Kelp and similar help you a lot with dispatching, but how to do something similar with contents?
[moritz]: like JSON::Schema
[Corion]: ambrus++ # more bugs than lines

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2016-12-08 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (141 votes). Check out past polls.