fork download
  1. #!/bin/bash
  2. url='http://e...content-available-to-author-only...e.org/project/branches/new-feature/src'
  3. url2='http://e...content-available-to-author-only...e.org/project/branches/new-feature'
  4. echo $url | perl -pe 's|^.*/branches/([^/]*)(?:/.*)?$|$1|'
  5. echo $url2 | perl -pe 's|^.*/branches/([^/]*)(?:/.*)?$|$1|'
  6.  
  7. echo $url | sed 's|^.*/branches/\([^/]*\)\(/.*\)\?$|\1|'
  8. echo $url2 | sed 's|^.*/branches/\([^/]*\)\(/.*\)\?$|\1|'
  9.  
  10. echo $url | grep -oP '/branches/\K[^/]+'
  11. echo $url2 | grep -oP '/branches/\K[^/]+'
  12.  
Success #stdin #stdout 0s 4528KB
stdin
Standard input is empty
stdout
new-feature
new-feature
new-feature
new-feature
new-feature
new-feature