Skip to content

tr does not support posix character class #2421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SuperSandro2000 opened this issue Jun 17, 2021 · 3 comments · Fixed by #2502
Closed

tr does not support posix character class #2421

SuperSandro2000 opened this issue Jun 17, 2021 · 3 comments · Fixed by #2502
Labels

Comments

@SuperSandro2000
Copy link
Contributor

I noticed that tr does not support the posix character classes. https://en.wikipedia.org/wiki/Regular_expression#Character_classes

gnu-coreutils:

$ echo 1.9 | tr -dC '[:digit:]'
19

uutils-coreutils:

$ echo 1.9 | result/bin/tr -dC '[:digit:]'
@hbina
Copy link
Contributor

hbina commented Jun 25, 2021

I think tr is broken in general,

coreutils on  master is 📦 v0.0.6 via 🦀 v1.53.0 took 34s 
❯ echo 1.9 | cargo run -- tr -dC '[:digit:]'
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/coreutils tr -dC '[:digit:]'`

coreutils on  master is 📦 v0.0.6 via 🦀 v1.53.0 
❯ echo 1.9 | cargo run -- tr -d '[:digit:]'
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/coreutils tr -d '[:digit:]'`
1.9

coreutils on  master is 📦 v0.0.6 via 🦀 v1.53.0 
❯ echo 1.9 | tr -d '[:digit:]'
.

coreutils on  master is 📦 v0.0.6 via 🦀 v1.53.0 
❯ echo 1.9 | cargo run -- tr -d '[:digit:]'
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/coreutils tr -d '[:digit:]'`
1.9

@hbina
Copy link
Contributor

hbina commented Jul 19, 2021

I have opened a PR here that's supposed to extend it to support all the available sequences. Any help is appreciated as I have no idea what most character classes represent. I would like to reduce the allocations performed here. I have some ideas, but any ideas is appreciated.

#2502

@tertsdiepraam tertsdiepraam linked a pull request Jul 19, 2021 that will close this issue
@jfinkels
Copy link
Collaborator

see also #556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants