in reply to Re: coloring patterns of an array
in thread coloring patterns of an array

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: coloring patterns of an array
by johngg (Canon) on Feb 05, 2007 at 11:05 UTC
    If you wish to match three or more "S"s then you can use the pattern /S{3,}/ and if you wanted to match, say, three to six of them then do /S{3,6}/. If you want to replace more than one occurrence of something in a string then make your substitution global by using the g modifier. Here is a bit of code to illustrate these points. Note that I capture the "S"s that I match using parentheses, "(" and ")", then use what I captured in the substitution as $1.

    $ perl -le ' -> $str = q{sfSSSfsdSSSSSseSShySSSScvbcv}; -> print $str; -> $str =~ s{(S{3,})}{<tag>$1</tag>}g; -> print $str;' sfSSSfsdSSSSSseSShySSSScvbcv sf<tag>SSS</tag>fsd<tag>SSSSS</tag>seSShy<tag>SSSS</tag>cvbcv $

    To look at previous nodes you have written go to your home node (you will see a "Tony1" link at the top of each page in the Monastery) and on that page you will see a link with the label "Writeups" next to it; click that and you will see all of your previous nodes.

    I hope this helps you.

    Cheers,

    JohnGG

    Update: Fixed typos.

Re^3: coloring patterns of an array
by Jenda (Abbot) on Feb 05, 2007 at 15:39 UTC

    "Hi" not "hai", "you" not "U", "are" not "r", "I" not "i"! And there are supposed to be spaces after ' or . and there's supposed to be a capital letter after a fullstop. Why do you expect anyone to spend time decrypting that mess if you apparently can't be bothered to spell right, capitalize correctly, use spaces and explain what are you trying to acomplish? If you program the way you write I'm not surprised the computer doesn't have the slightest idea what do you mean.

    Once you can explain in detail what exactly do you want you can get really helpful replies. Or even explain your task to the computer.

    P.S.: No, guys, this is not a matter of being nasty to a non native speaker who's struggling with the language. I don't mind the "if you can't able to understand" or "replay" instead of "reply" ... mistakes like that are to be expected. I just dislike the people who can't be bothered. To spell, to format, to explain, to think.

      Why do you expect anyone to spend time decrypting that mess if you apparently can't be bothered to spell right, capitalize correctly, use spaces and explain what are you trying to acomplish?

      Or even accomplish.

      It never fails, do it?

      SpeelFoo