It's Not 2015 Anymore!

The Rules

• Each submission must be a full program or a function.
• The program must take all instances of the string 2015 from the input (1 string), replace it with <s>2015</s>* (with <s> or <strike>). At the end, if there has been at least one 2015 in the string, you must add a newline and this string: *2016. I'm a year early!
• The program must not write anything to STDERR.
• The input will not contain <s>2015</s> or <strike>2015</strike>.

Note that there must be an interpreter so the submission can be tested.

• Submissions are scored in bytes, in an appropriate (pre-existing) encoding, usually (but not necessarily) UTF-8. Some languages, like Folders, are a bit tricky to score - if in doubt, please ask on Meta.
• This is , so shortest code wins

Examples

Input:

Hello! The date is 2015-12-24.

Output:

Hello! The date is 2015*-12-24.
*2016. I'm a year early!

Input:

foo bar baz quux

Output:

foo bar baz quux

Input:

12320151203205120151294201511271823

Output:

1232015*120320512015*12942015*11271823
*2016. I'm a year early!

Input:

Hello. The year is 2015...
2015.5...

Output:

Hello. The year is 2015*...
2015*.5...
*2016. I'm a year early!

The Snippet

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a leaderboard and b) as a list of winners per language.

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

• @downvoters what is wrong with this challenge?
– user46167
Jan 2 '16 at 1:41
• I find the challenge boring. It's a find-replace followed by a conditional concatenated string. Also, I don't like when functions are disallowed for no particular reason.
– xnor
Jan 2 '16 at 1:45
• Yes, but a challenge can be simple without being straightforward. Replacement or regex is a built-in in most langs. It means that's likely just the way to do it.
– xnor
Jan 2 '16 at 1:49
• Can we have any trailing whitespace? Jan 2 '16 at 2:30
• Not everyone agrees with @NBZ on that. And there are certainly more than enough trivial questions. If you post questions which have a negative score in the sandbox, don't be surprised to see them downvoted. Jan 2 '16 at 14:57

JavaScript ES6, 84 76 75 bytes

s=>(q=s.replace(/2015/g,"<s>$&</s>*"))+(s<q? *2016. I'm a year early!:"") This is pretty well golfed for JavaScript imo. This works by taking the input and replacing all instances of 2015 with <s>$&</s>* where $& is the value matched, but in this case, that's always 2015. Then, if the input is different from q, it'll add the *2016... string, otherwise, It'll add a blank string (nothing). • I think you can do (q!=s&&\n*2016. I'm a year early!) Jan 2 '16 at 2:21 • @CᴏɴᴏʀO'Bʀɪᴇɴ That seems to add "false" to the string when the condition is false :( Jan 2 '16 at 2:28 • Oh, dangit. That's bad :P Jan 2 '16 at 2:30 • Very interesting. Never knew about$& or any of the other special replacement patterns. Jan 2 '16 at 4:11

Ruby, 69 bytes

$><<gets.gsub(/2015/,'<s>\&</s>*') puts"*2016. I'm a year early!"if$&

Jolf, 60 bytes

Two parts, again.

oHρi"2015"+pd"s'$&'*" oH set H ρi"2015" to input string, replaced all 2015 with pd"s'$&'    $& crossed out. (pd is an apply tag function) + *" append an asterisk v-- unprintable +H|&?=Hi+S"*2016. I\'m a year early!'" +H|&?=Hi '" add ↓ to H if H != i; otherwise add empty string ('") +S"*2016. I\'m a year early!' a newline plus that string implicit printing Try it here! Bonus points for actually crossing out the text and conforming to the output examples? :3 • Technically against the rules. +1. Jan 2 '16 at 17:29 Python, 97 bytes a=raw_input();b=a.replace('2015','<s>2015</s>*');print a; if a!=b:print"*2016. I'm a year early!" This takes input from stdin, replaces any instances of 2015 with a strike, and prints the 2016 message if the two strings don't match. • couldn't you use a<b instead of a!=b? Jan 2 '16 at 20:22 Mathematica, 98 bytes a="2015";StringReplace[#,a->"<s>2015</s>*"]<>If[#~StringCount~a>0," *2016. I'm a year early!",""]& Once again, Mathematica's string processing uses many bytes... Pyth, 5251 50 bytes I- :z"2015""<s>2015</s>*"z." ytµbðï«»±é¢þnl¶Vû 𝔼𝕊𝕄𝕚𝕟, 49 chars / 93 bytes a=ïę ḟ*ṁ,<s>$&</s>*”)+(a≠ï?ɘƂ联Ӏఈ쁬Πā␎䁛␐줄쁰ꖈᲠ䉠耀#:⬯

Try it here (Firefox only).

Really straightforward. a=ïę ḟ*ṁ,'<s>$&</s>*”) nests all instances of 2015 (represented here as the result of 31*65) in strikethrough tags. Then, append the last string ('compressed' here) accordingly. Japt, 51 bytes Y=Ur2015"<s>$&</s>*")¥U?U:Y+
*2016. I'm a ye e§!

Try it online!

TeaScript, 59 bytes

(q=xg2015,"<s>$&</s>*"))+(x<q? *2016. I'm a year early!:u Try it online Explanation (q= // Assign q to... xg // input.replace 2015 // 2015 with. "..." // The string )) + // Add to.. (x<q? // If the input is different from replacement "..." // Add string to the end :u // Otherwise empty string • Downvote reason? This answer is perfectly valid, wth? Jan 2 '16 at 3:51 • They'll always downvote downgoat! Jan 2 '16 at 17:31 • @wizzwizz4 :( Maybe Upgoat is having better luck Jan 2 '16 at 17:32 • How legal are sockpuppet accounts? Jan 2 '16 at 17:34 • @wizzwizz4 I don't use them for evil, >:) just chatbots so it's fine. Jan 2 '16 at 17:36 05AB1E, 42 40 bytes Ž7ç©åi®®"<s>ÿ</s>*".:®>“*ÿ. I'm€…‚Œ‰€!“» Try it online! -2 thanks to Grimy Explanation Ž7ç©åi®®"<s>ÿ</s>*".:®>“*ÿ. I'm€…‚Œ‰€!“» Full Program Ž7ç© Pushes 2015 and copies it to the register å Checks if 2015 occurs in the input i If yes, do the following steps, else finish and output the input ®®"<s>ÿ</s>*" Pushes 2015 and "<s>2015</s>*" .: Replaces all instances of 2015 by </s>2015</s> in the input ®>“*ÿ. I'm€…‚Œ‰€!“ Push "*2016. I'm a year early!" » Concatenate both strings with a newline in between • The » is not needed when there is no replacement, so you can just drop the } for -1. May 28 '19 at 21:15 • May 28 '19 at 21:37 Arturo, 83 79 bytes$[s][r:replace s"2015""<s>2015</s>*"if r<>s['r++"\n*2016. I'm a year early!"]r]
• @Dr.Kameleon Suggested r<>s[suffix'r"\n*2016 ~> r<>s['r++"\n*2016. Apr 14 '21 at 11:51
• @JonathanFrech I'm not sure I'm too familiar with CodeGolf posting standards, but given that I am the original author of the language (Arturo), I just found this and decided to post my own - slightly shorter - solution. :) Apr 14 '21 at 11:58
• @Dr.Kameleon Nice to see you here and thank you for the golf! Here we usually suggest golfs in comments instead of editing the answer, so that, probably why you were received so harshly ;) Apr 14 '21 at 13:22
• @xigoi Well, I guess I know now lol. In any case, great to see an Arturo example here! Needless to say, I was more than pleasantly suprised! :) Apr 14 '21 at 14:19

(f)lex, 104 bytes

File 2015.l:

int n=0;
%%
"2015" ++n+puts("<s>2015</s>*");
%%
main(){yylex();n&&puts( "*2016. I'm a year early!\n");}

...no trailing newline.

Build:

$flex -o 2015.c 2015.l$ gcc 2015.c -o 2015 -lfl

Run:

$./2015 <<<'Hello! The date is 2015-12-24.' Hello! The date is <s>2015</s>*-12-24. *2016. I'm a year early!$ ./2015 <<<'foo bar baz quux'
foo bar baz quux
$./2015 <<<'12320151203205120151294201511271823' 123<s>2015</s>*12032051<s>2015</s>*1294<s>2015</s>*11271823 *2016. I'm a year early! I ran this using flex and gcc on Debian8, but I see no reason why it should fail in other environments using lex and/or a different C compiler. • Note it may bail out due to integer overflow. Aug 1 '19 at 10:45 C#, 152 bytes class A{static void Main(string[]a){System.Console.Write(a[0].Replace("2015","<s>2015</s>*")+(a[0].Contains("2015")?"\n*2016. I'm a year early!":""));}} Basic solution. Takes the string as the first argument. Gema, 57 bytes 2015=<s>$0</s>*@set{a;*2016. I'm a year early\!}
\Z=${a;} Sample run: bash-4.3$ gema -f not-2015.gema <<< 'Hello! The date is 2015-12-24.'
Hello! The date is <s>2015</s>*-12-24.
*2016. I'm a year early!

bash-4.3$gema -f not-2015.gema <<< 'foo bar baz quux' foo bar baz quux bash-4.3$ gema -f not-2015.gema <<< '12320151203205120151294201511271823'
123<s>2015</s>*12032051<s>2015</s>*1294<s>2015</s>*11271823
*2016. I'm a year early!

PowerShell, 81 79 bytes

-2 bytes thanks to mazzy

param($n)($z=$n-replace2015,'<s>$&</s>*')+"
*2016. I'm a year early!"*($z-ne$n)

Try it online!

Just a replace on the input and a conditional append with the 2016 line. You don't need many quotes or spaces in PowerShell either.

• 79 bytes :) May 28 '19 at 18:10

Stax, 36 bytes

ç┼↕+∙n7↔Qq┼╩↓╣ÇÖú];ⁿX£╞bëi⌐ñ▼Z♀φ6╛(<

Run and debug it

Unpacked, ungolfed, and commented, it looks like this.

_               push all of standard input
2015X           push 2015 and store it in the x register
$/c split string on "2015", and copy the result "<s>x</s>*"*P join with "<s>2015</s>*" and print D!C stop executing if split resulted in more than 1 element '*p print "*" without newline |Xp increment x register and print without newline print unterminated compressed literal ". I'm a year early!" Q_RUWZ)O-C! Run this one Retina, 49 45 64 61 60 54 bytes s2015.+$&¶*2016. I'm a year early!
\2015
<s>$&</s>* After numerous attempts I think this is the shortest Retina solution The first line matches 2015, the second line replaces the previous match (2015) with <s>$&</s>* where $& is the match's value or in this case, 2015. The \ removes the trailing newline from the output. The ` starts the regex.$ matches the end specifying we're trying to add a string to the end. The last line simply adds the string where becomes a newline. Retina uses the ISO-8859-1 encoding in which the is one byte

Try it online

ROOP, 110 bytes

1I
CW
|%|
V !
H
' "<s>2015</s>*"
2R !
0 #V
1 G #
5V #"\n*2016. I'm a year early!"
'| M #
-V #

#W
O#

This uses the R operator to replace all occurrences of the string 2015 in the input to <s>2015</s>*.Then, there is a comparison -- if the input string and the new one are different, then 1 is returned. Otherwise, 0 is returned. Then, M repeats the string \n*2016. I'm a year early that many times, i.e. if there are no changes, the string is blank, otherwise, the string is \n*2016. I'm a year early. Then, the strings are printed and the program terminates.

Above there is a 1 which is moved to the left and then falls to the operator H, which ends the program.

• It should print "*2016. I'm a year early!" only once
– user46167
Jan 3 '16 at 23:27
• That's what it does. Jan 3 '16 at 23:29
• Oh. I misinterpreted the usage of M.
– user46167
Jan 3 '16 at 23:32
• Use 1 or 0, sorry, English is not my native language. Feel free to improve the text if necessary. Jan 3 '16 at 23:35

Perl 5-p, 53 bytes

$\="\n*2016. I'm a year early!"if s|2015|<s>$&</s>*|g

Try it online!

Python 3.8 (pre-release), 80 bytes

lambda x:(b:=x.replace('2015','<s>2015<s>*'))+"\n*2016. I'm a year early!"*(b>x)

Try it online!

Saved 8 bytes thanks to squid

• Unless I've missed a way that this breaks it, 84 bytes May 28 '19 at 18:03
• 80 bytes May 28 '19 at 19:08
• @squid Okay, thanks! May 28 '19 at 22:18

JavaScript: 62 bytes

x=>x.replace('2015','<s>2015</s>')+"\n*2016. I'm a year early!"
• I'm afraid you missed a point: “\n*2016. I'm a year early!” has to be appended only if the input contained “2015” and your code actually made a replacement. So you must not append it to “foo bar baz quux”. Feb 2 '21 at 12:29