Skip to content
Mahmoud Ben Hassine edited this page Nov 21, 2015 · 4 revisions

tr

Synopsis

Replaces patterns with expressions in a stream of Strings.

Parameters

Name Type Mandatory Default
regexp String Yes N/A
replacement String Yes N/A

Example

Stream<String> stream = Stream.of("a", "ab");

UnixStream.unixify(stream)
   .tr("a", "b")
   .to(stdOut()); // prints "b", "bb"

// Or

UnixStream.from(stream)
   .pipe(tr("a", "b"))
   .to(stdOut()); // prints "b", "bb"

// Or

stream
    .map(Functions.tr("a", "b"))
    .forEach(System.out::println); // prints "b", "bb"
Clone this wiki locally