Skip to main content
Fixed Java minimum version
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 155
  • 394

Java 810, 120 bytes

r->{var i=java.math.BigInteger.ONE;for(var t="";;i=i.add(i.ONE),t=i.toString(36))if(t.matches(r))System.out.println(t);} 

Port of @l4m2's JavaScript answer, so make sure to upvote that answer as well.

Try it online.

Explanation:

r->{ // Method with String parameter and no return-type var i=java.math.BigInteger.ONE; // Loop-BigInteger `i`, starting at 1 for(var t=""; // Temp-String `t`, starting empty // Loop indefinitely: ; // After every iteration: i=i.add(i.ONE), // Increase `i` by 1 t=i.toString(36)) // Change `t` to `i` as base-36 string if(t.matches(r)) // If `t` fully† matches the input-regex: System.out.println(t);} // Print `t` with trailing newline 

† Java's String#matchesString#matches implicitly adds a leading ^ and trailing $ to match the regex on the entire String.

Java 8, 120 bytes

r->{var i=java.math.BigInteger.ONE;for(var t="";;i=i.add(i.ONE),t=i.toString(36))if(t.matches(r))System.out.println(t);} 

Port of @l4m2's JavaScript answer, so make sure to upvote that answer as well.

Try it online.

Explanation:

r->{ // Method with String parameter and no return-type var i=java.math.BigInteger.ONE; // Loop-BigInteger `i`, starting at 1 for(var t=""; // Temp-String `t`, starting empty // Loop indefinitely: ; // After every iteration: i=i.add(i.ONE), // Increase `i` by 1 t=i.toString(36)) // Change `t` to `i` as base-36 string if(t.matches(r)) // If `t` fully† matches the input-regex: System.out.println(t);} // Print `t` with trailing newline 

† Java's String#matches implicitly adds a leading ^ and trailing $ to match the regex on the entire String.

Java 10, 120 bytes

r->{var i=java.math.BigInteger.ONE;for(var t="";;i=i.add(i.ONE),t=i.toString(36))if(t.matches(r))System.out.println(t);} 

Port of @l4m2's JavaScript answer, so make sure to upvote that answer as well.

Try it online.

Explanation:

r->{ // Method with String parameter and no return-type var i=java.math.BigInteger.ONE; // Loop-BigInteger `i`, starting at 1 for(var t=""; // Temp-String `t`, starting empty // Loop indefinitely: ; // After every iteration: i=i.add(i.ONE), // Increase `i` by 1 t=i.toString(36)) // Change `t` to `i` as base-36 string if(t.matches(r)) // If `t` fully† matches the input-regex: System.out.println(t);} // Print `t` with trailing newline 

† Java's String#matches implicitly adds a leading ^ and trailing $ to match the regex on the entire String.

Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 155
  • 394

Java 8, 120 bytes

r->{var i=java.math.BigInteger.ONE;for(var t="";;i=i.add(i.ONE),t=i.toString(36))if(t.matches(r))System.out.println(t);} 

Port of @l4m2's JavaScript answer, so make sure to upvote that answer as well.

Try it online.

Explanation:

r->{ // Method with String parameter and no return-type var i=java.math.BigInteger.ONE; // Loop-BigInteger `i`, starting at 1 for(var t=""; // Temp-String `t`, starting empty // Loop indefinitely: ; // After every iteration: i=i.add(i.ONE), // Increase `i` by 1 t=i.toString(36)) // Change `t` to `i` as base-36 string if(t.matches(r)) // If `t` fully† matches the input-regex: System.out.println(t);} // Print `t` with trailing newline 

† Java's String#matches implicitly adds a leading ^ and trailing $ to match the regex on the entire String.