Perl regexp problem?

(. *?):(. *)/i Also, the I (case-insensitive matching) is redundant since you have no characters in your regex as well as the m which allows you to choose a different regex boundary character other than /. You also don't need the $_ =~ as Perl defaults to $_.

So you can reduce it to: /(.*):(. *):(. *):(.

*)/ ideone.com/TLepM.

Perfect but I found an other problem: if the line is – Kerby82 Dec 4 '10 at 15:24 You may want to make the first three non-greedy - if there are colons in the "rest of the line", you may not end up with what you expect. – Graeme Perrow Dec 4 '10 at 15:24 @Graeme Perrow exact! I have this problem how to solve this?

– Kerby82 Dec 4 '10 at 15:24 @Kerby82 Yup, noticed that as well thanks though. @Graeme Perrow Edited thanks. – marcog Dec 4 '10 at 15:25 @Kerby82: Add a?

, so you have /(.*? ):(. *?

):(. *?):(. *)/ – Graeme Perrow Dec 4 '10 at 15:25.

$x = "object1:object2:object3:rest of the line"; @x = split (":", $x); foreach $s (@x) { print "$s\n"; } This outputs: object1 object2 object3 rest of the line If you want to limit yourself to four fields regardless of the number of colons, you can use: $x = "object1:object2:object3:rest of the line with a : character"; @x = split (":", $x, 4); foreach $s (@x) { print "$s\n"; } which outputs: object1 object2 object3 rest of the line with a : character.

1 This is the better way. But can you add the count of 4 tokens like @FM has in his answer. – marcog Dec 4 '10 at 15:29 Sorry @paxdiablo but I can't use split :-) – Kerby82 Dec 4 '10 at 15:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions