Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( TrDelete trDeleteFlag = true TrNoDelete trDeleteFlag = false )
View Source
const ( TrSqueeze trSqueezeFlag = true TrNoSqueeze trSqueezeFlag = false )
View Source
const ( TrComplement trComplementFlag = true TrNoComplement trComplementFlag = false )
Variables ¶
This section is empty.
Functions ¶
func Tr ¶
Tr returns a Command that translates, deletes, or squeezes characters. from is the source character set (set1), to is the replacement character set (set2). Character ranges like "a-z" are expanded automatically.
Flags:
- TrDelete (-d): delete characters in set1
- TrSqueeze (-s): squeeze repeated characters
- TrComplement (-c): operate on the complement of set1
Example ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-tr"
)
func main() {
lines, _ := testable.TestLines(
command.Tr("a-z", "A-Z"),
"hello world\n",
)
for _, line := range lines {
fmt.Println(line)
}
}
Output: HELLO WORLD
Example (Delete) ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-tr"
)
func main() {
lines, _ := testable.TestLines(
command.Tr("aeiou", "", command.TrDelete),
"hello world\n",
)
for _, line := range lines {
fmt.Println(line)
}
}
Output: hll wrld
Example (Squeeze) ¶
package main
import (
"fmt"
"github.com/gloo-foo/testable"
command "github.com/gloo-foo/cmd-tr"
)
func main() {
lines, _ := testable.TestLines(
command.Tr(" ", "", command.TrSqueeze),
"hello world\n",
)
for _, line := range lines {
fmt.Println(line)
}
}
Output: hello world
Types ¶
Click to show internal directories.
Click to hide internal directories.