regex - Find n occurrences from group of characters -
Looking at the string, I think of printing "two" if I group given given I am very new to Pearl, so this is my view. From the general question: Output: xyz <
.
jxyl print two
jxyzl print nothing
my $ word = "jxyl"; @char = split //, $ word; My $ size = $ # four; $ Char eq for "z" ($ i = 0; $ i <$ size - 1; $ i ++) {if ($ char [i] ek "x" || $ char [i] eq " Y ") {print" two "; }} Can anyone tell me why he is not working properly?
perldoc -q count
Use warnings; Strict use; While (& lt; data & gt;) {chomp; My $ count = () = $ _ = ~ / [xyz] / g; Print "$ _ two \ n" if $ count == 2; } __DATA__ jxyl jxyzl jxxl
jxyl two jxxl two
Comments
Post a Comment