Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8830221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:01:25+00:00 2026-06-14T08:01:25+00:00

This is a really simple RegEx that isn’t working, and I can’t figure out

  • 0

This is a really simple RegEx that isn’t working, and I can’t figure out why. According to this, it should work.

I’m on a Mac (OS X 10.8.2).

script.sh

#!/bin/bash
ZIP="software-1.3-licensetypeone.zip"
VERSION=$(sed 's/software-//g;s/-(licensetypeone|licensetypetwo).zip//g' <<< $ZIP)

echo $VERSION

terminal

$ sh script.sh
1.3-licensetypeone.zip
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:01:26+00:00Added an answer on June 14, 2026 at 8:01 am

    Looking at the regex documentation for OS X 10.7.4 (but should apply to OP’s 10.8.2), it is mentioned in the last paragraph that

    Obsolete (basic) regular expressions differ in several respects. | is an ordinary character and there is no equivalent for its functionality…

    … The parentheses for nested subexpressions are \(' and )’…

    sed, without any options, uses basic regular expression (BRE).

    To use | in OS X or BSD’s sed, you need to enable extended regular expression (ERE) via -E option, i.e.

    sed -E 's/software-//g;s/-(licensetypeone|licensetypetwo).zip//g'
    

    p/s: \| in BRE is a GNU extension.


    Alternative ways to extract version number

    1. chop-chop (parameter expansion)

      VERSION=${ZIP#software-}
      VERSION=${VERSION%-license*.zip}
      
    2. sed

      VERSION=$(sed 's/software-\(.*\)-license.*/\1/' <<< "$ZIP")
      

      You don’t necessarily have to match strings word-by-word with shell patterns or regex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys having this really simple problem but cant seem to figure out have
I'm sure this is really simple, but I can't seem to get it working.
Really got stuck on this simple regex. Need it to validate a string, that
This may be a really simple regex but its one of those problems that
I've got this really simple piece of code that I thought was the correct
I'm going to run this really simple cod that will be compiled in visual
I'm sure this is really simple, but I can't for the life of me
I thought this would be really easy but I can't find a simple solution,
This might be really simple but i have a service that returns a string
This is just a really simple regex-question. I'd like to grab the last numbers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.