Y
Yannick Turgeon
Hello all,
I just started to use perl and I'm having a Regexp question:
Say we've got a file with this in it:
---- Beginning of file after this line --------
My list
A: cat
B: dog
C: horse
A: cow
C: bird
[...]
---- End of file before this line --------
What I'd like to do is to truncate everything before the animal
associated with the FIRST occurence of a label. Here with the label "A:"
I'd like to truncate everything before "cat" (and not before "cow")
# This truncate the string before "cow"
$myFileString =~ s/ ^ .* A:\ //sx;
Anybody can help?
One more thing. I use the "s" option but I don't undestand it quite well.
On the net, I've found the following:
"This option treats the string as a single line."
in which situation this could be a problem or something we don't want?
TIA
Yannick
I just started to use perl and I'm having a Regexp question:
Say we've got a file with this in it:
---- Beginning of file after this line --------
My list
A: cat
B: dog
C: horse
A: cow
C: bird
[...]
---- End of file before this line --------
What I'd like to do is to truncate everything before the animal
associated with the FIRST occurence of a label. Here with the label "A:"
I'd like to truncate everything before "cat" (and not before "cow")
# This truncate the string before "cow"
$myFileString =~ s/ ^ .* A:\ //sx;
Anybody can help?
One more thing. I use the "s" option but I don't undestand it quite well.
On the net, I've found the following:
"This option treats the string as a single line."
in which situation this could be a problem or something we don't want?
TIA
Yannick