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, 94 bytes

Java 10, 94 bytes

p->s->{for(var w:s.split(" "))if(w.startsWith(p))System.out.println(w.substring(p.length()));}

Try it online here.

Ungolfed:

p -> s -> { // lambda taking prefix and text as Strings in currying syntax
 for(var w:s.split(" ")) // split the String into words (delimited by a space); for each word ...
 if(w.startsWith(p)) // ... test whether p is a prefix ...
 System.out.println(w.substring(p.length())); // ... if it is, output the suffix
}

#Java 10, 94 bytes

p->s->{for(var w:s.split(" "))if(w.startsWith(p))System.out.println(w.substring(p.length()));}

Try it online here.

Ungolfed:

p -> s -> { // lambda taking prefix and text as Strings in currying syntax
 for(var w:s.split(" ")) // split the String into words (delimited by a space); for each word ...
 if(w.startsWith(p)) // ... test whether p is a prefix ...
 System.out.println(w.substring(p.length())); // ... if it is, output the suffix
}

Java 10, 94 bytes

p->s->{for(var w:s.split(" "))if(w.startsWith(p))System.out.println(w.substring(p.length()));}

Try it online here.

Ungolfed:

p -> s -> { // lambda taking prefix and text as Strings in currying syntax
 for(var w:s.split(" ")) // split the String into words (delimited by a space); for each word ...
 if(w.startsWith(p)) // ... test whether p is a prefix ...
 System.out.println(w.substring(p.length())); // ... if it is, output the suffix
}
Source Link
O.O.Balance
  • 1.6k
  • 1
  • 10
  • 19

#Java 10, 94 bytes

p->s->{for(var w:s.split(" "))if(w.startsWith(p))System.out.println(w.substring(p.length()));}

Try it online here.

Ungolfed:

p -> s -> { // lambda taking prefix and text as Strings in currying syntax
 for(var w:s.split(" ")) // split the String into words (delimited by a space); for each word ...
 if(w.startsWith(p)) // ... test whether p is a prefix ...
 System.out.println(w.substring(p.length())); // ... if it is, output the suffix
}

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