Skip to main content
Commonmark migration
Source Link

#Java 8, 27 bytes

Java 8, 27 bytes

s->s.replaceAll(".","$0$0")

Try it online.

Old 31 bytes answer before the rules got changed:

s->s.replaceAll("(?s).","$0$0")

NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All character(s) found in the match
  $0                            //  And again all character(s) found in the match

#Java 8, 27 bytes

s->s.replaceAll(".","$0$0")

Try it online.

Old 31 bytes answer before the rules got changed:

s->s.replaceAll("(?s).","$0$0")

NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All character(s) found in the match
  $0                            //  And again all character(s) found in the match

Java 8, 27 bytes

s->s.replaceAll(".","$0$0")

Try it online.

Old 31 bytes answer before the rules got changed:

s->s.replaceAll("(?s).","$0$0")

NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All character(s) found in the match
  $0                            //  And again all character(s) found in the match
added 400 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#Java 8, 3127 bytes

s->s.replaceAll(".","$0$0")

Try it online.

Old 31 bytes answer before the rules got changed:

s->s.replaceAll("(?s).","$0$0")

NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All character(s) found in the match
  $0                            //  And again all character(s) found in the match

#Java 8, 31 bytes

s->s.replaceAll("(?s).","$0$0")

NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All character(s) found in the match
  $0                            //  And again all character(s) found in the match

#Java 8, 27 bytes

s->s.replaceAll(".","$0$0")

Try it online.

Old 31 bytes answer before the rules got changed:

s->s.replaceAll("(?s).","$0$0")

NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All character(s) found in the match
  $0                            //  And again all character(s) found in the match
added 275 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#Java 8, 31 bytes

s->s.replaceAll("(?s).","$0$0")

Try it online. NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All characterscharacter(s) found in the match
  $0                            //  And again all characterscharacter(s) found in the match

#Java 8, 31 bytes

s->s.replaceAll("(?s).","$0$0")

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All characters found in the match
  $0                            //  And again all characters found in the match

#Java 8, 31 bytes

s->s.replaceAll("(?s).","$0$0")

NOTE: The suggestion of @EmbodimentOfIgnorance (\n|. instead of (?s). has been reverted, since it fails if the input contains \r. Thanks for reporting to @OlivierGrégoire.

Try it online.

Explanation:

s->                             // Method with String as both parameter and return-type
  s.replaceAll("(?s).","$0$0")  //  Regex-replace all matches with the replacement
                                //  And return the changed String as result

Regex explanation:

(?s).                           // Match:
(?s)                            //  Enable DOTALL mode so newlines and carriage returns
                                //  are treated as literal
    .                           //  A single character

$0$0                            // Replacement:
$0                              //  All character(s) found in the match
  $0                            //  And again all character(s) found in the match
Rollback to Revision 1
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading
added 93 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading