Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Problems with formatting the results of my regex

by Marshall (Monsignor)
on Jul 07, 2012 at 07:14 UTC ( #980452=note: print w/replies, xml ) Need Help??

in reply to Problems with formatting the results of my regex

Why make it more complicated than it needs to be?
#!/usr/bin/perl -w use strict; my $in ="20120704 00:05:53.46;CmdTask(0);EV;FBLdxPreAlignment rtn=0, Y +offset=-4278 "; #desired: 20120704,00:05:53.46,,,-4278 my ($num, $time, $offset) = $in =~ /\s*(\d+)\s+([\d:.]+).*=([-\d]+)\s* +$/; print "$num,$time,,,$offset\n"; __END__ prints: 20120704,00:05:53.46,,,-4278

Replies are listed 'Best First'.
Re^2: Problems with formatting the results of my regex
by superwombat (Novice) on Jul 07, 2012 at 08:19 UTC
    Thanks so much for the additional help. I know my Regexes are not as streamlined as they could/should be, and I really appreciate the advice on how to improve them beyond just fixing the issue I was having.
Re^2: Problems with formatting the results of my regex
by monsoon (Pilgrim) on Jul 07, 2012 at 07:53 UTC
    Doesn't match this: "20120704 00:05:53.46;CmdTask(0);EV;FBLdxPreAlignment rtn=0, Yoffset=-4278.25". The more I look at it the more I think the regex for $2 was supposed to match floating point numbers.
      Exactly, needs to match the possibility of a floating point number.
      The ".25" wasn't defined in the input spec, but this is fine addition that makes things more flexible.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980452]
[stevieb]: can anyone recommend a good IDE for C programming that has *proper* vim plugin support? I've tried Eclipse, Netbeans etc and just can't get anything to work properly on Linux. I'm open to paying, but not on some monthly/yearly plan (just a one-off cost)
[stevieb]: I'd go with CLion as it's very similar to what I use already (intelliJ for Perl, Pycharm for Python), but it's a recurring fee every year

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-01-18 19:09 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (163 votes). Check out past polls.