Skip to content
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

one more "?" operator bug? #31

Open
cbarbu opened this issue Feb 25, 2015 · 0 comments
Open

one more "?" operator bug? #31

cbarbu opened this issue Feb 25, 2015 · 0 comments
Labels

Comments

@cbarbu
Copy link

cbarbu commented Feb 25, 2015

[0-9] n times and [0-9]{n} behave differently when used with ? before:

a<-c("/Cajon_Criolla_20141024",

  •  "/Linon_20141115_20141130",
    
  •  "/Cat/LIQUID",
    
  •  "/c_puertas_20141206_20141107",
    
  •  "/C_Puertas_3_20141017_20141018",
    
  •  "/c_puertas_navidad_20141204_20141205"
    
  •  )
    

sub("(.?)([0-9]{8})(.)$","\2",a)
[1] "20141024" "20141130" "/Cat/LIQUID" "20141107" "20141018"
[6] "20141205"
sub("(.
?)([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])(.)$","\2",a)
[1] "20141024" "20141115" "/Cat/LIQUID" "20141206" "20141017"
[6] "20141204"

likely related to bugs #11 and #21 . See also original post on SO:

http://stackoverflow.com/questions/28725115/r-regex-capture-numbers-in-string-and-replacing-them-in-another-column-captu/28725655

@dag-erling dag-erling added the bug label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants