New Site Design!Hello, new world! againMake the PPCG FaviconHow much more reputation do I need?Generate a Stack Exchange FaviconRGB to Xterm Color ConverterLet's design a digit mosaicExecute Triangularity MoveSub-pixel ZoomingGenerate an RGB colour gridParsing text written the millitext font

Is there a radar system monitoring the UK mainland border?

Which are the methodologies for interpreting Vedas?

Why is it bad to use your whole foot in rock climbing

Can I get a photo of an Ancient Arrow?

The best in flight meal option for those suffering from reflux

Generate parentheses solution

Must a CPU have a GPU if the motherboard provides a display port (when there isn't any separate video card)?

Approach sick days in feedback meeting

usage of mir gefallen

Changing the PK column of a data extension without completely recreating it

How to import .txt file with missing data?

Why didn't all the iron and heavier elements find their way to the center of the accretion disc in the early solar system?

Must I use my personal social media account for work?

Do Veracrypt encrypted volumes have any kind of brute force protection?

List of interesting Quantitative Finance podcasts

Why does there seem to be an extreme lack of public trashcans in Taiwan?

Is Jesus the last Prophet?

How do I properly use a function under a class?

What is the theme of analysis?

Undocumented incompatibility between changes and siunitx?

Identification: what type of connector does the pictured socket take?

How to represent jealousy in a cute way?

Remove the small black rectangle that appears at the end of environment

What are some of the expected properties of metallic glasses and some steps to create them? (semi-ELI5)



New Site Design!


Hello, new world! againMake the PPCG FaviconHow much more reputation do I need?Generate a Stack Exchange FaviconRGB to Xterm Color ConverterLet's design a digit mosaicExecute Triangularity MoveSub-pixel ZoomingGenerate an RGB colour gridParsing text written the millitext font













13












$begingroup$


Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design!



(It's November now)



So, to celebrate, let's make a program that retroactively applies this design (oversimplified, of course)!



So, the most important changes are:



  • our new name is now Code Golf and Coding Challenges

  • our site is no longer the default blue color and is instead a nice dark green

So, given a string, change:




  • PPCG to CGCC


  • Programming Puzzles non-whitespace Code Golf to Code Golf same-thing Coding Challenges (for example, Programming Puzzles + Code Golf, and Code Golf, and & Code Golf would all be changed to Code Golf + Coding Challenges, and Coding Challenges, and & Code Golf.


  • #abc to #acb (swap blue to green and vice versa - just ignore the fact that green shouldn't logically become blue but I don't want to complicate the color shifting)


  • #abcdef to #abefcd (same as above)

Note that for the color swaps, you should accept any hexadecimal digit from 0-9 to a-f. You can choose what case of hex digit to require, but it must be consistent and the same from input to output.



Your substitutions can be case-sensitive, and if not, please specify how the output works.



The substitutions should only happen when the string is surrounded by word boundaries (including the start of the #). In other words, each of the specified substitutions should only occur if the match is at the edge of the string or is bordered by non-alphanumeric characters (on both sides).



Standard loopholes apply. This is a code-golf challenge, so the shortest code wins!



Examples



PPCG -> CGCC
Programming Puzzles or Code Golf -> Code Golf or Coding Challenges
PPCG stands for Programming Puzzles and Code Golf and its site color is #abf -> CGCC stands for Code Golf and Coding Challenges and its site color is #afb
The color #00f is much more intense than #5568ed -> The color #0f0 is much more intense than #55ed68


Important Update



(Thanks @tsh)



The Programming Puzzles ... Code Golf substitution rule can include the other rules inside of it (Programming Puzzles PPCG Code Golf is valid). In this case, you may choose whether or not the rules are applied, but it must be deterministic. I'm not requiring that you be consistent between PPCG and #... because answers seem to implement the rules in my list ordering which results in inconsistencies. This is just a clarification; I believe all current answers remain valid.










share|improve this question











$endgroup$







  • 2




    $begingroup$
    Should be apply the substitutions only if there are word boundaries around the substrings or everywhere?
    $endgroup$
    – Erik the Outgolfer
    8 hours ago










  • $begingroup$
    @EriktheOutgolfer Good catch; should have word boundaries. I will specify that; thanks.
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Define "word boundary" for a #; regex implementations generally don't consider a # to start a word.
    $endgroup$
    – tomsmeding
    8 hours ago










  • $begingroup$
    @tomsmeding I'm just going to make it so that the substitutions have to be at the edge of the string or have non-alnum around it
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Got test cases?
    $endgroup$
    – Value Ink
    8 hours ago















13












$begingroup$


Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design!



(It's November now)



So, to celebrate, let's make a program that retroactively applies this design (oversimplified, of course)!



So, the most important changes are:



  • our new name is now Code Golf and Coding Challenges

  • our site is no longer the default blue color and is instead a nice dark green

So, given a string, change:




  • PPCG to CGCC


  • Programming Puzzles non-whitespace Code Golf to Code Golf same-thing Coding Challenges (for example, Programming Puzzles + Code Golf, and Code Golf, and & Code Golf would all be changed to Code Golf + Coding Challenges, and Coding Challenges, and & Code Golf.


  • #abc to #acb (swap blue to green and vice versa - just ignore the fact that green shouldn't logically become blue but I don't want to complicate the color shifting)


  • #abcdef to #abefcd (same as above)

Note that for the color swaps, you should accept any hexadecimal digit from 0-9 to a-f. You can choose what case of hex digit to require, but it must be consistent and the same from input to output.



Your substitutions can be case-sensitive, and if not, please specify how the output works.



The substitutions should only happen when the string is surrounded by word boundaries (including the start of the #). In other words, each of the specified substitutions should only occur if the match is at the edge of the string or is bordered by non-alphanumeric characters (on both sides).



Standard loopholes apply. This is a code-golf challenge, so the shortest code wins!



Examples



PPCG -> CGCC
Programming Puzzles or Code Golf -> Code Golf or Coding Challenges
PPCG stands for Programming Puzzles and Code Golf and its site color is #abf -> CGCC stands for Code Golf and Coding Challenges and its site color is #afb
The color #00f is much more intense than #5568ed -> The color #0f0 is much more intense than #55ed68


Important Update



(Thanks @tsh)



The Programming Puzzles ... Code Golf substitution rule can include the other rules inside of it (Programming Puzzles PPCG Code Golf is valid). In this case, you may choose whether or not the rules are applied, but it must be deterministic. I'm not requiring that you be consistent between PPCG and #... because answers seem to implement the rules in my list ordering which results in inconsistencies. This is just a clarification; I believe all current answers remain valid.










share|improve this question











$endgroup$







  • 2




    $begingroup$
    Should be apply the substitutions only if there are word boundaries around the substrings or everywhere?
    $endgroup$
    – Erik the Outgolfer
    8 hours ago










  • $begingroup$
    @EriktheOutgolfer Good catch; should have word boundaries. I will specify that; thanks.
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Define "word boundary" for a #; regex implementations generally don't consider a # to start a word.
    $endgroup$
    – tomsmeding
    8 hours ago










  • $begingroup$
    @tomsmeding I'm just going to make it so that the substitutions have to be at the edge of the string or have non-alnum around it
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Got test cases?
    $endgroup$
    – Value Ink
    8 hours ago













13












13








13





$begingroup$


Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design!



(It's November now)



So, to celebrate, let's make a program that retroactively applies this design (oversimplified, of course)!



So, the most important changes are:



  • our new name is now Code Golf and Coding Challenges

  • our site is no longer the default blue color and is instead a nice dark green

So, given a string, change:




  • PPCG to CGCC


  • Programming Puzzles non-whitespace Code Golf to Code Golf same-thing Coding Challenges (for example, Programming Puzzles + Code Golf, and Code Golf, and & Code Golf would all be changed to Code Golf + Coding Challenges, and Coding Challenges, and & Code Golf.


  • #abc to #acb (swap blue to green and vice versa - just ignore the fact that green shouldn't logically become blue but I don't want to complicate the color shifting)


  • #abcdef to #abefcd (same as above)

Note that for the color swaps, you should accept any hexadecimal digit from 0-9 to a-f. You can choose what case of hex digit to require, but it must be consistent and the same from input to output.



Your substitutions can be case-sensitive, and if not, please specify how the output works.



The substitutions should only happen when the string is surrounded by word boundaries (including the start of the #). In other words, each of the specified substitutions should only occur if the match is at the edge of the string or is bordered by non-alphanumeric characters (on both sides).



Standard loopholes apply. This is a code-golf challenge, so the shortest code wins!



Examples



PPCG -> CGCC
Programming Puzzles or Code Golf -> Code Golf or Coding Challenges
PPCG stands for Programming Puzzles and Code Golf and its site color is #abf -> CGCC stands for Code Golf and Coding Challenges and its site color is #afb
The color #00f is much more intense than #5568ed -> The color #0f0 is much more intense than #55ed68


Important Update



(Thanks @tsh)



The Programming Puzzles ... Code Golf substitution rule can include the other rules inside of it (Programming Puzzles PPCG Code Golf is valid). In this case, you may choose whether or not the rules are applied, but it must be deterministic. I'm not requiring that you be consistent between PPCG and #... because answers seem to implement the rules in my list ordering which results in inconsistencies. This is just a clarification; I believe all current answers remain valid.










share|improve this question











$endgroup$




Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design!



(It's November now)



So, to celebrate, let's make a program that retroactively applies this design (oversimplified, of course)!



So, the most important changes are:



  • our new name is now Code Golf and Coding Challenges

  • our site is no longer the default blue color and is instead a nice dark green

So, given a string, change:




  • PPCG to CGCC


  • Programming Puzzles non-whitespace Code Golf to Code Golf same-thing Coding Challenges (for example, Programming Puzzles + Code Golf, and Code Golf, and & Code Golf would all be changed to Code Golf + Coding Challenges, and Coding Challenges, and & Code Golf.


  • #abc to #acb (swap blue to green and vice versa - just ignore the fact that green shouldn't logically become blue but I don't want to complicate the color shifting)


  • #abcdef to #abefcd (same as above)

Note that for the color swaps, you should accept any hexadecimal digit from 0-9 to a-f. You can choose what case of hex digit to require, but it must be consistent and the same from input to output.



Your substitutions can be case-sensitive, and if not, please specify how the output works.



The substitutions should only happen when the string is surrounded by word boundaries (including the start of the #). In other words, each of the specified substitutions should only occur if the match is at the edge of the string or is bordered by non-alphanumeric characters (on both sides).



Standard loopholes apply. This is a code-golf challenge, so the shortest code wins!



Examples



PPCG -> CGCC
Programming Puzzles or Code Golf -> Code Golf or Coding Challenges
PPCG stands for Programming Puzzles and Code Golf and its site color is #abf -> CGCC stands for Code Golf and Coding Challenges and its site color is #afb
The color #00f is much more intense than #5568ed -> The color #0f0 is much more intense than #55ed68


Important Update



(Thanks @tsh)



The Programming Puzzles ... Code Golf substitution rule can include the other rules inside of it (Programming Puzzles PPCG Code Golf is valid). In this case, you may choose whether or not the rules are applied, but it must be deterministic. I'm not requiring that you be consistent between PPCG and #... because answers seem to implement the rules in my list ordering which results in inconsistencies. This is just a clarification; I believe all current answers remain valid.







code-golf string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago







HyperNeutrino

















asked 9 hours ago









HyperNeutrinoHyperNeutrino

19.5k438150




19.5k438150







  • 2




    $begingroup$
    Should be apply the substitutions only if there are word boundaries around the substrings or everywhere?
    $endgroup$
    – Erik the Outgolfer
    8 hours ago










  • $begingroup$
    @EriktheOutgolfer Good catch; should have word boundaries. I will specify that; thanks.
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Define "word boundary" for a #; regex implementations generally don't consider a # to start a word.
    $endgroup$
    – tomsmeding
    8 hours ago










  • $begingroup$
    @tomsmeding I'm just going to make it so that the substitutions have to be at the edge of the string or have non-alnum around it
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Got test cases?
    $endgroup$
    – Value Ink
    8 hours ago












  • 2




    $begingroup$
    Should be apply the substitutions only if there are word boundaries around the substrings or everywhere?
    $endgroup$
    – Erik the Outgolfer
    8 hours ago










  • $begingroup$
    @EriktheOutgolfer Good catch; should have word boundaries. I will specify that; thanks.
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Define "word boundary" for a #; regex implementations generally don't consider a # to start a word.
    $endgroup$
    – tomsmeding
    8 hours ago










  • $begingroup$
    @tomsmeding I'm just going to make it so that the substitutions have to be at the edge of the string or have non-alnum around it
    $endgroup$
    – HyperNeutrino
    8 hours ago










  • $begingroup$
    Got test cases?
    $endgroup$
    – Value Ink
    8 hours ago







2




2




$begingroup$
Should be apply the substitutions only if there are word boundaries around the substrings or everywhere?
$endgroup$
– Erik the Outgolfer
8 hours ago




$begingroup$
Should be apply the substitutions only if there are word boundaries around the substrings or everywhere?
$endgroup$
– Erik the Outgolfer
8 hours ago












$begingroup$
@EriktheOutgolfer Good catch; should have word boundaries. I will specify that; thanks.
$endgroup$
– HyperNeutrino
8 hours ago




$begingroup$
@EriktheOutgolfer Good catch; should have word boundaries. I will specify that; thanks.
$endgroup$
– HyperNeutrino
8 hours ago












$begingroup$
Define "word boundary" for a #; regex implementations generally don't consider a # to start a word.
$endgroup$
– tomsmeding
8 hours ago




$begingroup$
Define "word boundary" for a #; regex implementations generally don't consider a # to start a word.
$endgroup$
– tomsmeding
8 hours ago












$begingroup$
@tomsmeding I'm just going to make it so that the substitutions have to be at the edge of the string or have non-alnum around it
$endgroup$
– HyperNeutrino
8 hours ago




$begingroup$
@tomsmeding I'm just going to make it so that the substitutions have to be at the edge of the string or have non-alnum around it
$endgroup$
– HyperNeutrino
8 hours ago












$begingroup$
Got test cases?
$endgroup$
– Value Ink
8 hours ago




$begingroup$
Got test cases?
$endgroup$
– Value Ink
8 hours ago










8 Answers
8






active

oldest

votes


















3












$begingroup$


Ruby -p, 165 164 159 bytes



It ended up being very similar to the sed answer, but it abuses Ruby's string interpolation to duplicate the hex group matching ([da-f]1,2) within the third regex three times instead of needing to repeat the whole thing again.



  • -1 byte from @randomdude999.

  • -5 bytes from leveraging @Xcali's Perl solution

gsub /bPPCGb/,"CGCC"
gsub /bProgramming Puzzles( S+ )(Code Golf)b/,'21Coding Challenges'
[1,2].map


Try it online!






share|improve this answer











$endgroup$












  • $begingroup$
    Doesn't using 1,2 break with hex inputs of length 4 or 5, e.g. #aabbc? Edit: it does (this example should not be replaced because it's not a valid hex color).
    $endgroup$
    – randomdude999
    7 hours ago











  • $begingroup$
    Fails for this case (- is a non-alphanumeric character).
    $endgroup$
    – Erik the Outgolfer
    7 hours ago










  • $begingroup$
    @randomdude999 yeah, good catch. Added a check for that.
    $endgroup$
    – Value Ink
    7 hours ago










  • $begingroup$
    @EriktheOutgolfer yeah, I guess. "Word boundaries" with the # is a bit ambiguous since /b/ doesn't register with it next to another non-alphanumeric, but I did the change anyways for no byte change (replacing S with w)
    $endgroup$
    – Value Ink
    7 hours ago










  • $begingroup$
    Can't you replace your (?<!w) with my (^|W) for 1 char?
    $endgroup$
    – tomsmeding
    7 hours ago


















2












$begingroup$

GNU sed -E, 198 chars



s/bPPCGb/CGCC/g
s/bProgramming Puzzles( S* Cod)e Golfb/Code Golf1ing Challenges/g
s/((^|W)#[0-9a-f])([0-9a-f])([0-9a-f])b/143/g
s/((^|W)#[0-9a-f]2)([0-9a-f]2)([0-9a-f]2)b/143/g


Runnable using e.g. sed -E 'the above'; newlines can either be included literally, or replaced with ; if you so wish. Both work.



@HyperNeutrino come on that word boundary rule is stupid. Look what I had to do in the # case.



Yes, I didn't even try. :P



+9 by @Value Ink






share|improve this answer











$endgroup$








  • 1




    $begingroup$
    Flags are no longer included in byte counts so you can take out the extra byte and call it "GNU sed -E" instead.
    $endgroup$
    – Value Ink
    8 hours ago










  • $begingroup$
    @ValueInk Whaaaaat? I have apparently been severely out of touch with this community for too long to not notice that. I think it's a good rule though. Also, thanks for mentioning.
    $endgroup$
    – tomsmeding
    8 hours ago










  • $begingroup$
    doesn't sed's regex matching allow using d as a shortcut for 0-9? could save you a whole 6 bytes
    $endgroup$
    – randomdude999
    8 hours ago










  • $begingroup$
    Also I just noticed, you return "Programming Puzzles or Coding Challenges" for the second test case instead of the expected "Code Golf or Coding Challenges".
    $endgroup$
    – Value Ink
    8 hours ago










  • $begingroup$
    @randomdude999 The re_format(7) man page on my Mac seems to suggest that sed should support d, but apparently it doesn't. ¯_(ツ)_/¯
    $endgroup$
    – tomsmeding
    7 hours ago



















2












$begingroup$


Retina 0.8.2, 153 bytes



bPPCGb
CGCC
bProgramming Puzzles( S+ )(Code Golf)b
$2$1Coding Challenges
B(#[da-f]([da-f])?)([da-f](?(2)[da-f]))([da-f](?(2)[da-f]))b
$1$4$3


Try it online! Link includes test cases. All substitutions are case sensitive. Assumes normal regex word characters are acceptable so that B# matches only #s that don't follow a word character.






share|improve this answer









$endgroup$




















    2












    $begingroup$


    Python 2, 240 bytes





    import re
    lambda x,s=re.sub,b='(?<!w)',e='(?!w)',h='([da-f]',t=r'#132':s(b+'#%s2)'%h+h+'2)%s2)'%h+e,t,s(b+'#%s)'%h+h+')%s)'%h+e,t,s(b+'Programming Puzzles( S+ Cod)e Golf'+e,r'Code Golf1ing Challenges',s(b+'PPCG'+e,'CGCC',x))))


    Try it online!






    share|improve this answer









    $endgroup$




















      2












      $begingroup$


      C++ (gcc), 270 bytes





      #import<regex>
      #import<string>
      auto f=[](auto s)typeof(s)h"([\da-f]1,2)",R[][2]"bPPCG","CGCC","bProgramming Puzzles( \S+ )(Code Golf)","$2$1Coding Challenges","B#"+h+h+h,"#$1$3$2";for(auto r:R)s=std::regex_replace(s,std::regex('\'+r[0]+"\b"),r[1]);return s;;


      Try it online!






      share|improve this answer









      $endgroup$




















        1












        $begingroup$


        Pyth, 177 173 162 bytes



        K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC"." z¶NZI°Pÿúd(MÜ_BöIkxnqä'u)"." s6#~ÍN³=<nñu/GÎg"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


        Here's a version without Pyth's string compression mechanisms (aka it's safe to copy-paste):



        K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC""\bProgramming Puzzles( S+ )(Code Golf)\b""\2\1Coding Challenges"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


        Try it online!



        This ended up being really long because I tried to be as pedantic as possible with the regexes. I did sneak in some tricks to make the regexes shorter and I tried to compress every string possible, but most of them either didn't get smaller or couldn't be pasted into TIO properly.



        Explanation:



        K"#\2\4\3" # defines K to that string
        J"(^|(?<=W))#" # defines J to the regex part
        # 4 nested regex replace operations
        ::::
        jb.z # input to first replace: all the input lines joined together
        "\bPPCG\b" # first regex: find PPCG
        "CGCC" # first replacement
        ."<compressed text 1>" # Second regex: compressed string, evaluates to "\bProgramming Puzzles( S+ )(Code Golf)\b"
        ."<compressed text 2>" # second replacement: compressed, evaluates to "\2\1Coding Challenges"
        ++J*3"([da-f]2)""\b" # third regex: G, then 3 copies of the larger string, then "\b" (matches 6-digit hex literals)
        K # third replacement
        ++J*3"([da-f])""\b" # fourth regex: similar to third, but without 2, making it match 3-digit hex literals
        K # fourth replacement


        -11 thanks to a better regex from Value Ink's Ruby answer






        share|improve this answer










        New contributor



        randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        $endgroup$




















          1












          $begingroup$


          Perl 5 -p, 152 145 bytes



          @ValueInk saves 7 bytes





          s/bPPCGb/CGCC/g;s/bProgramming Puzzles( S+ )(Code Golf)b/$2$1Coding Challenges/g;for$a(1,2)$p="([a-f0-9]$a)"x3;s/(^


          Try it online!






          share|improve this answer











          $endgroup$












          • $begingroup$
            ( S+ )(Code Golf)b/$2$1Coding saves 2 bytes. Also the last regex can end with just a b instead of (?=s|$)
            $endgroup$
            – Value Ink
            3 hours ago










          • $begingroup$
            I was working on that first one while you were typing that comment. I've made the other change to save some bytes. Thanks!
            $endgroup$
            – Xcali
            3 hours ago


















          1












          $begingroup$


          JavaScript (Node.js), 174 bytes





          s=>s[R='replace'](/bPPCGb/g,'CGCC')[R](/bProgramming Puzzles( S+ )(Code Golf)b/g,'$2$1Coding Challenges')[R](/B#(?=([da-f]3)1,2b)(.+?)(..??)(..??)b/ig,'#$2$4$3')


          Try it online!






          share|improve this answer











          $endgroup$












          • $begingroup$
            Fails on test case #abcde because the regex qualifier 3,6 matches between 3 and 6 characters, instead of either 3 or 6 which I assume you were going for.
            $endgroup$
            – Value Ink
            2 hours ago










          • $begingroup$
            @ValueInk nice catch. fixed with +5 bytes.
            $endgroup$
            – tsh
            1 hour ago











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "200"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f186720%2fnew-site-design%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          8 Answers
          8






          active

          oldest

          votes








          8 Answers
          8






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3












          $begingroup$


          Ruby -p, 165 164 159 bytes



          It ended up being very similar to the sed answer, but it abuses Ruby's string interpolation to duplicate the hex group matching ([da-f]1,2) within the third regex three times instead of needing to repeat the whole thing again.



          • -1 byte from @randomdude999.

          • -5 bytes from leveraging @Xcali's Perl solution

          gsub /bPPCGb/,"CGCC"
          gsub /bProgramming Puzzles( S+ )(Code Golf)b/,'21Coding Challenges'
          [1,2].map


          Try it online!






          share|improve this answer











          $endgroup$












          • $begingroup$
            Doesn't using 1,2 break with hex inputs of length 4 or 5, e.g. #aabbc? Edit: it does (this example should not be replaced because it's not a valid hex color).
            $endgroup$
            – randomdude999
            7 hours ago











          • $begingroup$
            Fails for this case (- is a non-alphanumeric character).
            $endgroup$
            – Erik the Outgolfer
            7 hours ago










          • $begingroup$
            @randomdude999 yeah, good catch. Added a check for that.
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            @EriktheOutgolfer yeah, I guess. "Word boundaries" with the # is a bit ambiguous since /b/ doesn't register with it next to another non-alphanumeric, but I did the change anyways for no byte change (replacing S with w)
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            Can't you replace your (?<!w) with my (^|W) for 1 char?
            $endgroup$
            – tomsmeding
            7 hours ago















          3












          $begingroup$


          Ruby -p, 165 164 159 bytes



          It ended up being very similar to the sed answer, but it abuses Ruby's string interpolation to duplicate the hex group matching ([da-f]1,2) within the third regex three times instead of needing to repeat the whole thing again.



          • -1 byte from @randomdude999.

          • -5 bytes from leveraging @Xcali's Perl solution

          gsub /bPPCGb/,"CGCC"
          gsub /bProgramming Puzzles( S+ )(Code Golf)b/,'21Coding Challenges'
          [1,2].map


          Try it online!






          share|improve this answer











          $endgroup$












          • $begingroup$
            Doesn't using 1,2 break with hex inputs of length 4 or 5, e.g. #aabbc? Edit: it does (this example should not be replaced because it's not a valid hex color).
            $endgroup$
            – randomdude999
            7 hours ago











          • $begingroup$
            Fails for this case (- is a non-alphanumeric character).
            $endgroup$
            – Erik the Outgolfer
            7 hours ago










          • $begingroup$
            @randomdude999 yeah, good catch. Added a check for that.
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            @EriktheOutgolfer yeah, I guess. "Word boundaries" with the # is a bit ambiguous since /b/ doesn't register with it next to another non-alphanumeric, but I did the change anyways for no byte change (replacing S with w)
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            Can't you replace your (?<!w) with my (^|W) for 1 char?
            $endgroup$
            – tomsmeding
            7 hours ago













          3












          3








          3





          $begingroup$


          Ruby -p, 165 164 159 bytes



          It ended up being very similar to the sed answer, but it abuses Ruby's string interpolation to duplicate the hex group matching ([da-f]1,2) within the third regex three times instead of needing to repeat the whole thing again.



          • -1 byte from @randomdude999.

          • -5 bytes from leveraging @Xcali's Perl solution

          gsub /bPPCGb/,"CGCC"
          gsub /bProgramming Puzzles( S+ )(Code Golf)b/,'21Coding Challenges'
          [1,2].map


          Try it online!






          share|improve this answer











          $endgroup$




          Ruby -p, 165 164 159 bytes



          It ended up being very similar to the sed answer, but it abuses Ruby's string interpolation to duplicate the hex group matching ([da-f]1,2) within the third regex three times instead of needing to repeat the whole thing again.



          • -1 byte from @randomdude999.

          • -5 bytes from leveraging @Xcali's Perl solution

          gsub /bPPCGb/,"CGCC"
          gsub /bProgramming Puzzles( S+ )(Code Golf)b/,'21Coding Challenges'
          [1,2].map


          Try it online!







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered 7 hours ago









          Value InkValue Ink

          8,315731




          8,315731











          • $begingroup$
            Doesn't using 1,2 break with hex inputs of length 4 or 5, e.g. #aabbc? Edit: it does (this example should not be replaced because it's not a valid hex color).
            $endgroup$
            – randomdude999
            7 hours ago











          • $begingroup$
            Fails for this case (- is a non-alphanumeric character).
            $endgroup$
            – Erik the Outgolfer
            7 hours ago










          • $begingroup$
            @randomdude999 yeah, good catch. Added a check for that.
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            @EriktheOutgolfer yeah, I guess. "Word boundaries" with the # is a bit ambiguous since /b/ doesn't register with it next to another non-alphanumeric, but I did the change anyways for no byte change (replacing S with w)
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            Can't you replace your (?<!w) with my (^|W) for 1 char?
            $endgroup$
            – tomsmeding
            7 hours ago
















          • $begingroup$
            Doesn't using 1,2 break with hex inputs of length 4 or 5, e.g. #aabbc? Edit: it does (this example should not be replaced because it's not a valid hex color).
            $endgroup$
            – randomdude999
            7 hours ago











          • $begingroup$
            Fails for this case (- is a non-alphanumeric character).
            $endgroup$
            – Erik the Outgolfer
            7 hours ago










          • $begingroup$
            @randomdude999 yeah, good catch. Added a check for that.
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            @EriktheOutgolfer yeah, I guess. "Word boundaries" with the # is a bit ambiguous since /b/ doesn't register with it next to another non-alphanumeric, but I did the change anyways for no byte change (replacing S with w)
            $endgroup$
            – Value Ink
            7 hours ago










          • $begingroup$
            Can't you replace your (?<!w) with my (^|W) for 1 char?
            $endgroup$
            – tomsmeding
            7 hours ago















          $begingroup$
          Doesn't using 1,2 break with hex inputs of length 4 or 5, e.g. #aabbc? Edit: it does (this example should not be replaced because it's not a valid hex color).
          $endgroup$
          – randomdude999
          7 hours ago





          $begingroup$
          Doesn't using 1,2 break with hex inputs of length 4 or 5, e.g. #aabbc? Edit: it does (this example should not be replaced because it's not a valid hex color).
          $endgroup$
          – randomdude999
          7 hours ago













          $begingroup$
          Fails for this case (- is a non-alphanumeric character).
          $endgroup$
          – Erik the Outgolfer
          7 hours ago




          $begingroup$
          Fails for this case (- is a non-alphanumeric character).
          $endgroup$
          – Erik the Outgolfer
          7 hours ago












          $begingroup$
          @randomdude999 yeah, good catch. Added a check for that.
          $endgroup$
          – Value Ink
          7 hours ago




          $begingroup$
          @randomdude999 yeah, good catch. Added a check for that.
          $endgroup$
          – Value Ink
          7 hours ago












          $begingroup$
          @EriktheOutgolfer yeah, I guess. "Word boundaries" with the # is a bit ambiguous since /b/ doesn't register with it next to another non-alphanumeric, but I did the change anyways for no byte change (replacing S with w)
          $endgroup$
          – Value Ink
          7 hours ago




          $begingroup$
          @EriktheOutgolfer yeah, I guess. "Word boundaries" with the # is a bit ambiguous since /b/ doesn't register with it next to another non-alphanumeric, but I did the change anyways for no byte change (replacing S with w)
          $endgroup$
          – Value Ink
          7 hours ago












          $begingroup$
          Can't you replace your (?<!w) with my (^|W) for 1 char?
          $endgroup$
          – tomsmeding
          7 hours ago




          $begingroup$
          Can't you replace your (?<!w) with my (^|W) for 1 char?
          $endgroup$
          – tomsmeding
          7 hours ago











          2












          $begingroup$

          GNU sed -E, 198 chars



          s/bPPCGb/CGCC/g
          s/bProgramming Puzzles( S* Cod)e Golfb/Code Golf1ing Challenges/g
          s/((^|W)#[0-9a-f])([0-9a-f])([0-9a-f])b/143/g
          s/((^|W)#[0-9a-f]2)([0-9a-f]2)([0-9a-f]2)b/143/g


          Runnable using e.g. sed -E 'the above'; newlines can either be included literally, or replaced with ; if you so wish. Both work.



          @HyperNeutrino come on that word boundary rule is stupid. Look what I had to do in the # case.



          Yes, I didn't even try. :P



          +9 by @Value Ink






          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Flags are no longer included in byte counts so you can take out the extra byte and call it "GNU sed -E" instead.
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @ValueInk Whaaaaat? I have apparently been severely out of touch with this community for too long to not notice that. I think it's a good rule though. Also, thanks for mentioning.
            $endgroup$
            – tomsmeding
            8 hours ago










          • $begingroup$
            doesn't sed's regex matching allow using d as a shortcut for 0-9? could save you a whole 6 bytes
            $endgroup$
            – randomdude999
            8 hours ago










          • $begingroup$
            Also I just noticed, you return "Programming Puzzles or Coding Challenges" for the second test case instead of the expected "Code Golf or Coding Challenges".
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @randomdude999 The re_format(7) man page on my Mac seems to suggest that sed should support d, but apparently it doesn't. ¯_(ツ)_/¯
            $endgroup$
            – tomsmeding
            7 hours ago
















          2












          $begingroup$

          GNU sed -E, 198 chars



          s/bPPCGb/CGCC/g
          s/bProgramming Puzzles( S* Cod)e Golfb/Code Golf1ing Challenges/g
          s/((^|W)#[0-9a-f])([0-9a-f])([0-9a-f])b/143/g
          s/((^|W)#[0-9a-f]2)([0-9a-f]2)([0-9a-f]2)b/143/g


          Runnable using e.g. sed -E 'the above'; newlines can either be included literally, or replaced with ; if you so wish. Both work.



          @HyperNeutrino come on that word boundary rule is stupid. Look what I had to do in the # case.



          Yes, I didn't even try. :P



          +9 by @Value Ink






          share|improve this answer











          $endgroup$








          • 1




            $begingroup$
            Flags are no longer included in byte counts so you can take out the extra byte and call it "GNU sed -E" instead.
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @ValueInk Whaaaaat? I have apparently been severely out of touch with this community for too long to not notice that. I think it's a good rule though. Also, thanks for mentioning.
            $endgroup$
            – tomsmeding
            8 hours ago










          • $begingroup$
            doesn't sed's regex matching allow using d as a shortcut for 0-9? could save you a whole 6 bytes
            $endgroup$
            – randomdude999
            8 hours ago










          • $begingroup$
            Also I just noticed, you return "Programming Puzzles or Coding Challenges" for the second test case instead of the expected "Code Golf or Coding Challenges".
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @randomdude999 The re_format(7) man page on my Mac seems to suggest that sed should support d, but apparently it doesn't. ¯_(ツ)_/¯
            $endgroup$
            – tomsmeding
            7 hours ago














          2












          2








          2





          $begingroup$

          GNU sed -E, 198 chars



          s/bPPCGb/CGCC/g
          s/bProgramming Puzzles( S* Cod)e Golfb/Code Golf1ing Challenges/g
          s/((^|W)#[0-9a-f])([0-9a-f])([0-9a-f])b/143/g
          s/((^|W)#[0-9a-f]2)([0-9a-f]2)([0-9a-f]2)b/143/g


          Runnable using e.g. sed -E 'the above'; newlines can either be included literally, or replaced with ; if you so wish. Both work.



          @HyperNeutrino come on that word boundary rule is stupid. Look what I had to do in the # case.



          Yes, I didn't even try. :P



          +9 by @Value Ink






          share|improve this answer











          $endgroup$



          GNU sed -E, 198 chars



          s/bPPCGb/CGCC/g
          s/bProgramming Puzzles( S* Cod)e Golfb/Code Golf1ing Challenges/g
          s/((^|W)#[0-9a-f])([0-9a-f])([0-9a-f])b/143/g
          s/((^|W)#[0-9a-f]2)([0-9a-f]2)([0-9a-f]2)b/143/g


          Runnable using e.g. sed -E 'the above'; newlines can either be included literally, or replaced with ; if you so wish. Both work.



          @HyperNeutrino come on that word boundary rule is stupid. Look what I had to do in the # case.



          Yes, I didn't even try. :P



          +9 by @Value Ink







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 7 hours ago

























          answered 8 hours ago









          tomsmedingtomsmeding

          1,8891219




          1,8891219







          • 1




            $begingroup$
            Flags are no longer included in byte counts so you can take out the extra byte and call it "GNU sed -E" instead.
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @ValueInk Whaaaaat? I have apparently been severely out of touch with this community for too long to not notice that. I think it's a good rule though. Also, thanks for mentioning.
            $endgroup$
            – tomsmeding
            8 hours ago










          • $begingroup$
            doesn't sed's regex matching allow using d as a shortcut for 0-9? could save you a whole 6 bytes
            $endgroup$
            – randomdude999
            8 hours ago










          • $begingroup$
            Also I just noticed, you return "Programming Puzzles or Coding Challenges" for the second test case instead of the expected "Code Golf or Coding Challenges".
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @randomdude999 The re_format(7) man page on my Mac seems to suggest that sed should support d, but apparently it doesn't. ¯_(ツ)_/¯
            $endgroup$
            – tomsmeding
            7 hours ago













          • 1




            $begingroup$
            Flags are no longer included in byte counts so you can take out the extra byte and call it "GNU sed -E" instead.
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @ValueInk Whaaaaat? I have apparently been severely out of touch with this community for too long to not notice that. I think it's a good rule though. Also, thanks for mentioning.
            $endgroup$
            – tomsmeding
            8 hours ago










          • $begingroup$
            doesn't sed's regex matching allow using d as a shortcut for 0-9? could save you a whole 6 bytes
            $endgroup$
            – randomdude999
            8 hours ago










          • $begingroup$
            Also I just noticed, you return "Programming Puzzles or Coding Challenges" for the second test case instead of the expected "Code Golf or Coding Challenges".
            $endgroup$
            – Value Ink
            8 hours ago










          • $begingroup$
            @randomdude999 The re_format(7) man page on my Mac seems to suggest that sed should support d, but apparently it doesn't. ¯_(ツ)_/¯
            $endgroup$
            – tomsmeding
            7 hours ago








          1




          1




          $begingroup$
          Flags are no longer included in byte counts so you can take out the extra byte and call it "GNU sed -E" instead.
          $endgroup$
          – Value Ink
          8 hours ago




          $begingroup$
          Flags are no longer included in byte counts so you can take out the extra byte and call it "GNU sed -E" instead.
          $endgroup$
          – Value Ink
          8 hours ago












          $begingroup$
          @ValueInk Whaaaaat? I have apparently been severely out of touch with this community for too long to not notice that. I think it's a good rule though. Also, thanks for mentioning.
          $endgroup$
          – tomsmeding
          8 hours ago




          $begingroup$
          @ValueInk Whaaaaat? I have apparently been severely out of touch with this community for too long to not notice that. I think it's a good rule though. Also, thanks for mentioning.
          $endgroup$
          – tomsmeding
          8 hours ago












          $begingroup$
          doesn't sed's regex matching allow using d as a shortcut for 0-9? could save you a whole 6 bytes
          $endgroup$
          – randomdude999
          8 hours ago




          $begingroup$
          doesn't sed's regex matching allow using d as a shortcut for 0-9? could save you a whole 6 bytes
          $endgroup$
          – randomdude999
          8 hours ago












          $begingroup$
          Also I just noticed, you return "Programming Puzzles or Coding Challenges" for the second test case instead of the expected "Code Golf or Coding Challenges".
          $endgroup$
          – Value Ink
          8 hours ago




          $begingroup$
          Also I just noticed, you return "Programming Puzzles or Coding Challenges" for the second test case instead of the expected "Code Golf or Coding Challenges".
          $endgroup$
          – Value Ink
          8 hours ago












          $begingroup$
          @randomdude999 The re_format(7) man page on my Mac seems to suggest that sed should support d, but apparently it doesn't. ¯_(ツ)_/¯
          $endgroup$
          – tomsmeding
          7 hours ago





          $begingroup$
          @randomdude999 The re_format(7) man page on my Mac seems to suggest that sed should support d, but apparently it doesn't. ¯_(ツ)_/¯
          $endgroup$
          – tomsmeding
          7 hours ago












          2












          $begingroup$


          Retina 0.8.2, 153 bytes



          bPPCGb
          CGCC
          bProgramming Puzzles( S+ )(Code Golf)b
          $2$1Coding Challenges
          B(#[da-f]([da-f])?)([da-f](?(2)[da-f]))([da-f](?(2)[da-f]))b
          $1$4$3


          Try it online! Link includes test cases. All substitutions are case sensitive. Assumes normal regex word characters are acceptable so that B# matches only #s that don't follow a word character.






          share|improve this answer









          $endgroup$

















            2












            $begingroup$


            Retina 0.8.2, 153 bytes



            bPPCGb
            CGCC
            bProgramming Puzzles( S+ )(Code Golf)b
            $2$1Coding Challenges
            B(#[da-f]([da-f])?)([da-f](?(2)[da-f]))([da-f](?(2)[da-f]))b
            $1$4$3


            Try it online! Link includes test cases. All substitutions are case sensitive. Assumes normal regex word characters are acceptable so that B# matches only #s that don't follow a word character.






            share|improve this answer









            $endgroup$















              2












              2








              2





              $begingroup$


              Retina 0.8.2, 153 bytes



              bPPCGb
              CGCC
              bProgramming Puzzles( S+ )(Code Golf)b
              $2$1Coding Challenges
              B(#[da-f]([da-f])?)([da-f](?(2)[da-f]))([da-f](?(2)[da-f]))b
              $1$4$3


              Try it online! Link includes test cases. All substitutions are case sensitive. Assumes normal regex word characters are acceptable so that B# matches only #s that don't follow a word character.






              share|improve this answer









              $endgroup$




              Retina 0.8.2, 153 bytes



              bPPCGb
              CGCC
              bProgramming Puzzles( S+ )(Code Golf)b
              $2$1Coding Challenges
              B(#[da-f]([da-f])?)([da-f](?(2)[da-f]))([da-f](?(2)[da-f]))b
              $1$4$3


              Try it online! Link includes test cases. All substitutions are case sensitive. Assumes normal regex word characters are acceptable so that B# matches only #s that don't follow a word character.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 6 hours ago









              NeilNeil

              85k845183




              85k845183





















                  2












                  $begingroup$


                  Python 2, 240 bytes





                  import re
                  lambda x,s=re.sub,b='(?<!w)',e='(?!w)',h='([da-f]',t=r'#132':s(b+'#%s2)'%h+h+'2)%s2)'%h+e,t,s(b+'#%s)'%h+h+')%s)'%h+e,t,s(b+'Programming Puzzles( S+ Cod)e Golf'+e,r'Code Golf1ing Challenges',s(b+'PPCG'+e,'CGCC',x))))


                  Try it online!






                  share|improve this answer









                  $endgroup$

















                    2












                    $begingroup$


                    Python 2, 240 bytes





                    import re
                    lambda x,s=re.sub,b='(?<!w)',e='(?!w)',h='([da-f]',t=r'#132':s(b+'#%s2)'%h+h+'2)%s2)'%h+e,t,s(b+'#%s)'%h+h+')%s)'%h+e,t,s(b+'Programming Puzzles( S+ Cod)e Golf'+e,r'Code Golf1ing Challenges',s(b+'PPCG'+e,'CGCC',x))))


                    Try it online!






                    share|improve this answer









                    $endgroup$















                      2












                      2








                      2





                      $begingroup$


                      Python 2, 240 bytes





                      import re
                      lambda x,s=re.sub,b='(?<!w)',e='(?!w)',h='([da-f]',t=r'#132':s(b+'#%s2)'%h+h+'2)%s2)'%h+e,t,s(b+'#%s)'%h+h+')%s)'%h+e,t,s(b+'Programming Puzzles( S+ Cod)e Golf'+e,r'Code Golf1ing Challenges',s(b+'PPCG'+e,'CGCC',x))))


                      Try it online!






                      share|improve this answer









                      $endgroup$




                      Python 2, 240 bytes





                      import re
                      lambda x,s=re.sub,b='(?<!w)',e='(?!w)',h='([da-f]',t=r'#132':s(b+'#%s2)'%h+h+'2)%s2)'%h+e,t,s(b+'#%s)'%h+h+')%s)'%h+e,t,s(b+'Programming Puzzles( S+ Cod)e Golf'+e,r'Code Golf1ing Challenges',s(b+'PPCG'+e,'CGCC',x))))


                      Try it online!







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 6 hours ago









                      Erik the OutgolferErik the Outgolfer

                      33.8k430107




                      33.8k430107





















                          2












                          $begingroup$


                          C++ (gcc), 270 bytes





                          #import<regex>
                          #import<string>
                          auto f=[](auto s)typeof(s)h"([\da-f]1,2)",R[][2]"bPPCG","CGCC","bProgramming Puzzles( \S+ )(Code Golf)","$2$1Coding Challenges","B#"+h+h+h,"#$1$3$2";for(auto r:R)s=std::regex_replace(s,std::regex('\'+r[0]+"\b"),r[1]);return s;;


                          Try it online!






                          share|improve this answer









                          $endgroup$

















                            2












                            $begingroup$


                            C++ (gcc), 270 bytes





                            #import<regex>
                            #import<string>
                            auto f=[](auto s)typeof(s)h"([\da-f]1,2)",R[][2]"bPPCG","CGCC","bProgramming Puzzles( \S+ )(Code Golf)","$2$1Coding Challenges","B#"+h+h+h,"#$1$3$2";for(auto r:R)s=std::regex_replace(s,std::regex('\'+r[0]+"\b"),r[1]);return s;;


                            Try it online!






                            share|improve this answer









                            $endgroup$















                              2












                              2








                              2





                              $begingroup$


                              C++ (gcc), 270 bytes





                              #import<regex>
                              #import<string>
                              auto f=[](auto s)typeof(s)h"([\da-f]1,2)",R[][2]"bPPCG","CGCC","bProgramming Puzzles( \S+ )(Code Golf)","$2$1Coding Challenges","B#"+h+h+h,"#$1$3$2";for(auto r:R)s=std::regex_replace(s,std::regex('\'+r[0]+"\b"),r[1]);return s;;


                              Try it online!






                              share|improve this answer









                              $endgroup$




                              C++ (gcc), 270 bytes





                              #import<regex>
                              #import<string>
                              auto f=[](auto s)typeof(s)h"([\da-f]1,2)",R[][2]"bPPCG","CGCC","bProgramming Puzzles( \S+ )(Code Golf)","$2$1Coding Challenges","B#"+h+h+h,"#$1$3$2";for(auto r:R)s=std::regex_replace(s,std::regex('\'+r[0]+"\b"),r[1]);return s;;


                              Try it online!







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 5 hours ago









                              gastropnergastropner

                              2,4201612




                              2,4201612





















                                  1












                                  $begingroup$


                                  Pyth, 177 173 162 bytes



                                  K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC"." z¶NZI°Pÿúd(MÜ_BöIkxnqä'u)"." s6#~ÍN³=<nñu/GÎg"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                  Here's a version without Pyth's string compression mechanisms (aka it's safe to copy-paste):



                                  K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC""\bProgramming Puzzles( S+ )(Code Golf)\b""\2\1Coding Challenges"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                  Try it online!



                                  This ended up being really long because I tried to be as pedantic as possible with the regexes. I did sneak in some tricks to make the regexes shorter and I tried to compress every string possible, but most of them either didn't get smaller or couldn't be pasted into TIO properly.



                                  Explanation:



                                  K"#\2\4\3" # defines K to that string
                                  J"(^|(?<=W))#" # defines J to the regex part
                                  # 4 nested regex replace operations
                                  ::::
                                  jb.z # input to first replace: all the input lines joined together
                                  "\bPPCG\b" # first regex: find PPCG
                                  "CGCC" # first replacement
                                  ."<compressed text 1>" # Second regex: compressed string, evaluates to "\bProgramming Puzzles( S+ )(Code Golf)\b"
                                  ."<compressed text 2>" # second replacement: compressed, evaluates to "\2\1Coding Challenges"
                                  ++J*3"([da-f]2)""\b" # third regex: G, then 3 copies of the larger string, then "\b" (matches 6-digit hex literals)
                                  K # third replacement
                                  ++J*3"([da-f])""\b" # fourth regex: similar to third, but without 2, making it match 3-digit hex literals
                                  K # fourth replacement


                                  -11 thanks to a better regex from Value Ink's Ruby answer






                                  share|improve this answer










                                  New contributor



                                  randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                  Check out our Code of Conduct.





                                  $endgroup$

















                                    1












                                    $begingroup$


                                    Pyth, 177 173 162 bytes



                                    K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC"." z¶NZI°Pÿúd(MÜ_BöIkxnqä'u)"." s6#~ÍN³=<nñu/GÎg"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                    Here's a version without Pyth's string compression mechanisms (aka it's safe to copy-paste):



                                    K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC""\bProgramming Puzzles( S+ )(Code Golf)\b""\2\1Coding Challenges"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                    Try it online!



                                    This ended up being really long because I tried to be as pedantic as possible with the regexes. I did sneak in some tricks to make the regexes shorter and I tried to compress every string possible, but most of them either didn't get smaller or couldn't be pasted into TIO properly.



                                    Explanation:



                                    K"#\2\4\3" # defines K to that string
                                    J"(^|(?<=W))#" # defines J to the regex part
                                    # 4 nested regex replace operations
                                    ::::
                                    jb.z # input to first replace: all the input lines joined together
                                    "\bPPCG\b" # first regex: find PPCG
                                    "CGCC" # first replacement
                                    ."<compressed text 1>" # Second regex: compressed string, evaluates to "\bProgramming Puzzles( S+ )(Code Golf)\b"
                                    ."<compressed text 2>" # second replacement: compressed, evaluates to "\2\1Coding Challenges"
                                    ++J*3"([da-f]2)""\b" # third regex: G, then 3 copies of the larger string, then "\b" (matches 6-digit hex literals)
                                    K # third replacement
                                    ++J*3"([da-f])""\b" # fourth regex: similar to third, but without 2, making it match 3-digit hex literals
                                    K # fourth replacement


                                    -11 thanks to a better regex from Value Ink's Ruby answer






                                    share|improve this answer










                                    New contributor



                                    randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                    Check out our Code of Conduct.





                                    $endgroup$















                                      1












                                      1








                                      1





                                      $begingroup$


                                      Pyth, 177 173 162 bytes



                                      K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC"." z¶NZI°Pÿúd(MÜ_BöIkxnqä'u)"." s6#~ÍN³=<nñu/GÎg"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                      Here's a version without Pyth's string compression mechanisms (aka it's safe to copy-paste):



                                      K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC""\bProgramming Puzzles( S+ )(Code Golf)\b""\2\1Coding Challenges"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                      Try it online!



                                      This ended up being really long because I tried to be as pedantic as possible with the regexes. I did sneak in some tricks to make the regexes shorter and I tried to compress every string possible, but most of them either didn't get smaller or couldn't be pasted into TIO properly.



                                      Explanation:



                                      K"#\2\4\3" # defines K to that string
                                      J"(^|(?<=W))#" # defines J to the regex part
                                      # 4 nested regex replace operations
                                      ::::
                                      jb.z # input to first replace: all the input lines joined together
                                      "\bPPCG\b" # first regex: find PPCG
                                      "CGCC" # first replacement
                                      ."<compressed text 1>" # Second regex: compressed string, evaluates to "\bProgramming Puzzles( S+ )(Code Golf)\b"
                                      ."<compressed text 2>" # second replacement: compressed, evaluates to "\2\1Coding Challenges"
                                      ++J*3"([da-f]2)""\b" # third regex: G, then 3 copies of the larger string, then "\b" (matches 6-digit hex literals)
                                      K # third replacement
                                      ++J*3"([da-f])""\b" # fourth regex: similar to third, but without 2, making it match 3-digit hex literals
                                      K # fourth replacement


                                      -11 thanks to a better regex from Value Ink's Ruby answer






                                      share|improve this answer










                                      New contributor



                                      randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.





                                      $endgroup$




                                      Pyth, 177 173 162 bytes



                                      K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC"." z¶NZI°Pÿúd(MÜ_BöIkxnqä'u)"." s6#~ÍN³=<nñu/GÎg"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                      Here's a version without Pyth's string compression mechanisms (aka it's safe to copy-paste):



                                      K"#\2\4\3"J"(^|(?<=W))#"::::jb.z"\bPPCG\b""CGCC""\bProgramming Puzzles( S+ )(Code Golf)\b""\2\1Coding Challenges"++J*3"([da-f]2)""\b"K++J*3"([da-f])""\b"K


                                      Try it online!



                                      This ended up being really long because I tried to be as pedantic as possible with the regexes. I did sneak in some tricks to make the regexes shorter and I tried to compress every string possible, but most of them either didn't get smaller or couldn't be pasted into TIO properly.



                                      Explanation:



                                      K"#\2\4\3" # defines K to that string
                                      J"(^|(?<=W))#" # defines J to the regex part
                                      # 4 nested regex replace operations
                                      ::::
                                      jb.z # input to first replace: all the input lines joined together
                                      "\bPPCG\b" # first regex: find PPCG
                                      "CGCC" # first replacement
                                      ."<compressed text 1>" # Second regex: compressed string, evaluates to "\bProgramming Puzzles( S+ )(Code Golf)\b"
                                      ."<compressed text 2>" # second replacement: compressed, evaluates to "\2\1Coding Challenges"
                                      ++J*3"([da-f]2)""\b" # third regex: G, then 3 copies of the larger string, then "\b" (matches 6-digit hex literals)
                                      K # third replacement
                                      ++J*3"([da-f])""\b" # fourth regex: similar to third, but without 2, making it match 3-digit hex literals
                                      K # fourth replacement


                                      -11 thanks to a better regex from Value Ink's Ruby answer







                                      share|improve this answer










                                      New contributor



                                      randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.








                                      share|improve this answer



                                      share|improve this answer








                                      edited 6 hours ago





















                                      New contributor



                                      randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.








                                      answered 7 hours ago









                                      randomdude999randomdude999

                                      1114




                                      1114




                                      New contributor



                                      randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.




                                      New contributor




                                      randomdude999 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                      Check out our Code of Conduct.























                                          1












                                          $begingroup$


                                          Perl 5 -p, 152 145 bytes



                                          @ValueInk saves 7 bytes





                                          s/bPPCGb/CGCC/g;s/bProgramming Puzzles( S+ )(Code Golf)b/$2$1Coding Challenges/g;for$a(1,2)$p="([a-f0-9]$a)"x3;s/(^


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$












                                          • $begingroup$
                                            ( S+ )(Code Golf)b/$2$1Coding saves 2 bytes. Also the last regex can end with just a b instead of (?=s|$)
                                            $endgroup$
                                            – Value Ink
                                            3 hours ago










                                          • $begingroup$
                                            I was working on that first one while you were typing that comment. I've made the other change to save some bytes. Thanks!
                                            $endgroup$
                                            – Xcali
                                            3 hours ago















                                          1












                                          $begingroup$


                                          Perl 5 -p, 152 145 bytes



                                          @ValueInk saves 7 bytes





                                          s/bPPCGb/CGCC/g;s/bProgramming Puzzles( S+ )(Code Golf)b/$2$1Coding Challenges/g;for$a(1,2)$p="([a-f0-9]$a)"x3;s/(^


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$












                                          • $begingroup$
                                            ( S+ )(Code Golf)b/$2$1Coding saves 2 bytes. Also the last regex can end with just a b instead of (?=s|$)
                                            $endgroup$
                                            – Value Ink
                                            3 hours ago










                                          • $begingroup$
                                            I was working on that first one while you were typing that comment. I've made the other change to save some bytes. Thanks!
                                            $endgroup$
                                            – Xcali
                                            3 hours ago













                                          1












                                          1








                                          1





                                          $begingroup$


                                          Perl 5 -p, 152 145 bytes



                                          @ValueInk saves 7 bytes





                                          s/bPPCGb/CGCC/g;s/bProgramming Puzzles( S+ )(Code Golf)b/$2$1Coding Challenges/g;for$a(1,2)$p="([a-f0-9]$a)"x3;s/(^


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$




                                          Perl 5 -p, 152 145 bytes



                                          @ValueInk saves 7 bytes





                                          s/bPPCGb/CGCC/g;s/bProgramming Puzzles( S+ )(Code Golf)b/$2$1Coding Challenges/g;for$a(1,2)$p="([a-f0-9]$a)"x3;s/(^


                                          Try it online!







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 3 hours ago

























                                          answered 5 hours ago









                                          XcaliXcali

                                          6,028523




                                          6,028523











                                          • $begingroup$
                                            ( S+ )(Code Golf)b/$2$1Coding saves 2 bytes. Also the last regex can end with just a b instead of (?=s|$)
                                            $endgroup$
                                            – Value Ink
                                            3 hours ago










                                          • $begingroup$
                                            I was working on that first one while you were typing that comment. I've made the other change to save some bytes. Thanks!
                                            $endgroup$
                                            – Xcali
                                            3 hours ago
















                                          • $begingroup$
                                            ( S+ )(Code Golf)b/$2$1Coding saves 2 bytes. Also the last regex can end with just a b instead of (?=s|$)
                                            $endgroup$
                                            – Value Ink
                                            3 hours ago










                                          • $begingroup$
                                            I was working on that first one while you were typing that comment. I've made the other change to save some bytes. Thanks!
                                            $endgroup$
                                            – Xcali
                                            3 hours ago















                                          $begingroup$
                                          ( S+ )(Code Golf)b/$2$1Coding saves 2 bytes. Also the last regex can end with just a b instead of (?=s|$)
                                          $endgroup$
                                          – Value Ink
                                          3 hours ago




                                          $begingroup$
                                          ( S+ )(Code Golf)b/$2$1Coding saves 2 bytes. Also the last regex can end with just a b instead of (?=s|$)
                                          $endgroup$
                                          – Value Ink
                                          3 hours ago












                                          $begingroup$
                                          I was working on that first one while you were typing that comment. I've made the other change to save some bytes. Thanks!
                                          $endgroup$
                                          – Xcali
                                          3 hours ago




                                          $begingroup$
                                          I was working on that first one while you were typing that comment. I've made the other change to save some bytes. Thanks!
                                          $endgroup$
                                          – Xcali
                                          3 hours ago











                                          1












                                          $begingroup$


                                          JavaScript (Node.js), 174 bytes





                                          s=>s[R='replace'](/bPPCGb/g,'CGCC')[R](/bProgramming Puzzles( S+ )(Code Golf)b/g,'$2$1Coding Challenges')[R](/B#(?=([da-f]3)1,2b)(.+?)(..??)(..??)b/ig,'#$2$4$3')


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$












                                          • $begingroup$
                                            Fails on test case #abcde because the regex qualifier 3,6 matches between 3 and 6 characters, instead of either 3 or 6 which I assume you were going for.
                                            $endgroup$
                                            – Value Ink
                                            2 hours ago










                                          • $begingroup$
                                            @ValueInk nice catch. fixed with +5 bytes.
                                            $endgroup$
                                            – tsh
                                            1 hour ago















                                          1












                                          $begingroup$


                                          JavaScript (Node.js), 174 bytes





                                          s=>s[R='replace'](/bPPCGb/g,'CGCC')[R](/bProgramming Puzzles( S+ )(Code Golf)b/g,'$2$1Coding Challenges')[R](/B#(?=([da-f]3)1,2b)(.+?)(..??)(..??)b/ig,'#$2$4$3')


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$












                                          • $begingroup$
                                            Fails on test case #abcde because the regex qualifier 3,6 matches between 3 and 6 characters, instead of either 3 or 6 which I assume you were going for.
                                            $endgroup$
                                            – Value Ink
                                            2 hours ago










                                          • $begingroup$
                                            @ValueInk nice catch. fixed with +5 bytes.
                                            $endgroup$
                                            – tsh
                                            1 hour ago













                                          1












                                          1








                                          1





                                          $begingroup$


                                          JavaScript (Node.js), 174 bytes





                                          s=>s[R='replace'](/bPPCGb/g,'CGCC')[R](/bProgramming Puzzles( S+ )(Code Golf)b/g,'$2$1Coding Challenges')[R](/B#(?=([da-f]3)1,2b)(.+?)(..??)(..??)b/ig,'#$2$4$3')


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$




                                          JavaScript (Node.js), 174 bytes





                                          s=>s[R='replace'](/bPPCGb/g,'CGCC')[R](/bProgramming Puzzles( S+ )(Code Golf)b/g,'$2$1Coding Challenges')[R](/B#(?=([da-f]3)1,2b)(.+?)(..??)(..??)b/ig,'#$2$4$3')


                                          Try it online!







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 1 hour ago

























                                          answered 2 hours ago









                                          tshtsh

                                          9,88711655




                                          9,88711655











                                          • $begingroup$
                                            Fails on test case #abcde because the regex qualifier 3,6 matches between 3 and 6 characters, instead of either 3 or 6 which I assume you were going for.
                                            $endgroup$
                                            – Value Ink
                                            2 hours ago










                                          • $begingroup$
                                            @ValueInk nice catch. fixed with +5 bytes.
                                            $endgroup$
                                            – tsh
                                            1 hour ago
















                                          • $begingroup$
                                            Fails on test case #abcde because the regex qualifier 3,6 matches between 3 and 6 characters, instead of either 3 or 6 which I assume you were going for.
                                            $endgroup$
                                            – Value Ink
                                            2 hours ago










                                          • $begingroup$
                                            @ValueInk nice catch. fixed with +5 bytes.
                                            $endgroup$
                                            – tsh
                                            1 hour ago















                                          $begingroup$
                                          Fails on test case #abcde because the regex qualifier 3,6 matches between 3 and 6 characters, instead of either 3 or 6 which I assume you were going for.
                                          $endgroup$
                                          – Value Ink
                                          2 hours ago




                                          $begingroup$
                                          Fails on test case #abcde because the regex qualifier 3,6 matches between 3 and 6 characters, instead of either 3 or 6 which I assume you were going for.
                                          $endgroup$
                                          – Value Ink
                                          2 hours ago












                                          $begingroup$
                                          @ValueInk nice catch. fixed with +5 bytes.
                                          $endgroup$
                                          – tsh
                                          1 hour ago




                                          $begingroup$
                                          @ValueInk nice catch. fixed with +5 bytes.
                                          $endgroup$
                                          – tsh
                                          1 hour ago

















                                          draft saved

                                          draft discarded
















































                                          If this is an answer to a challenge…



                                          • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                          • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                            Explanations of your answer make it more interesting to read and are very much encouraged.


                                          • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                          More generally…



                                          • …Please make sure to answer the question and provide sufficient detail.


                                          • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f186720%2fnew-site-design%23new-answer', 'question_page');

                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

                                          Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

                                          19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу