Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Java 10, 141 bytes

Java 10, 141 bytes

s->c->{var r=s.split("\\"+c);var r=a[0],t;for(int i=0;++i<a.length;r+=t.isEmpty()?"":(char)(t.charAt(0)&~32)+t.substring(1))t=a[i];return r;}

Try it online.

Explanation:

s->c->{ // Method with String and character parameters and String return-type
 var r=s.split("\\"+c); // Split String by character (with potential regex char)
 var r=a[0], // Result-String, starting at the first item
 t; // Temp-String to reduce bytes
 for(int i=0;++i<a.length;// Loop in the range [1, length_of_array)
 r+= // After every iteration: append the result-String with:
 t.isEmpty()? // If the current item empty:
 "" // Append nothing
 : // Else:
 (char)(t.charAt(0)&~32)
 // Capitalize the first character
 +t.substring(1)) // And append the other characters as is
 t=a[i]; // Set `t` to the current String-item of the array
 return r;} // Return the result-String

#Java 10, 141 bytes

s->c->{var r=s.split("\\"+c);var r=a[0],t;for(int i=0;++i<a.length;r+=t.isEmpty()?"":(char)(t.charAt(0)&~32)+t.substring(1))t=a[i];return r;}

Try it online.

Explanation:

s->c->{ // Method with String and character parameters and String return-type
 var r=s.split("\\"+c); // Split String by character (with potential regex char)
 var r=a[0], // Result-String, starting at the first item
 t; // Temp-String to reduce bytes
 for(int i=0;++i<a.length;// Loop in the range [1, length_of_array)
 r+= // After every iteration: append the result-String with:
 t.isEmpty()? // If the current item empty:
 "" // Append nothing
 : // Else:
 (char)(t.charAt(0)&~32)
 // Capitalize the first character
 +t.substring(1)) // And append the other characters as is
 t=a[i]; // Set `t` to the current String-item of the array
 return r;} // Return the result-String

Java 10, 141 bytes

s->c->{var r=s.split("\\"+c);var r=a[0],t;for(int i=0;++i<a.length;r+=t.isEmpty()?"":(char)(t.charAt(0)&~32)+t.substring(1))t=a[i];return r;}

Try it online.

Explanation:

s->c->{ // Method with String and character parameters and String return-type
 var r=s.split("\\"+c); // Split String by character (with potential regex char)
 var r=a[0], // Result-String, starting at the first item
 t; // Temp-String to reduce bytes
 for(int i=0;++i<a.length;// Loop in the range [1, length_of_array)
 r+= // After every iteration: append the result-String with:
 t.isEmpty()? // If the current item empty:
 "" // Append nothing
 : // Else:
 (char)(t.charAt(0)&~32)
 // Capitalize the first character
 +t.substring(1)) // And append the other characters as is
 t=a[i]; // Set `t` to the current String-item of the array
 return r;} // Return the result-String
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 10, 141 bytes

s->c->{var r=s.split("\\"+c);var r=a[0],t;for(int i=0;++i<a.length;r+=t.isEmpty()?"":(char)(t.charAt(0)&~32)+t.substring(1))t=a[i];return r;}

Try it online.

Explanation:

s->c->{ // Method with String and character parameters and String return-type
 var r=s.split("\\"+c); // Split String by character (with potential regex char)
 var r=a[0], // Result-String, starting at the first item
 t; // Temp-String to reduce bytes
 for(int i=0;++i<a.length;// Loop in the range [1, length_of_array)
 r+= // After every iteration: append the result-String with:
 t.isEmpty()? // If the current item empty:
 "" // Append nothing
 : // Else:
 (char)(t.charAt(0)&~32)
 // Capitalize the first character
 +t.substring(1)) // And append the other characters as is
 t=a[i]; // Set `t` to the current String-item of the array
 return r;} // Return the result-String

AltStyle によって変換されたページ (->オリジナル) /