Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • (?=...) is not valid POSIX ERE syntax. Be sure you use the right regex language variant. Commented Apr 18, 2020 at 1:16
  • ERE doesn't allow non-greedy modifiers either. +? and *? don't mean anything here. Commented Apr 18, 2020 at 1:17
  • regex='([^/.]+)([.]zip)?$' may not be exactly what you want, but its validity does demonstrate that grouping is not the part of your original expression that's illegal. Commented Apr 18, 2020 at 1:20
  • BTW, you need to use quotes when assigning to the regex variable, and not use quotes when expanding that variable, to get consistent and reliable behavior. Commented Apr 18, 2020 at 1:23
  • Thank you for the help Charles. I have been testing on regexr which used the javascript ERE so that explains why it doesn't work with bash. Thanks for the extra tips. I'll be trying to just get "file" and not "file.zip" now. Commented Apr 18, 2020 at 1:25