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

  • Home
  • SEARCH
  • 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 193689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:31:54+00:00 2026-05-11T16:31:54+00:00

So, folks, I have this self crafted pattern that works. After some hours (I

  • 0

So, folks, I have this self crafted pattern that works. After some hours (I am no regex guru) this puppy evolved to parse curl PUT output for me:

   ^\s*([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)
    \s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)

(CR in text only for formatting)

It gives me ‘groups’ that I access–it works! Yet the coder in me sees the repetition of a pattern, and it bugs the frack out of me. I’ve seen perl how-small-is-your-pattern contests over the years that makes me think this could be much smaller. But my attempts to slap a * in it have failed miserably.

So, The Question Is: how do write this pattern in a more concise way so that I can still pull out my target groups?

It probably doesn’t matter, but here are the groups I am after:

$1: percent finished
$2: size uploaded so far
$6: size to upload
$8: average upload rate 

Update: Further background can by found on a blog post of mine (How to configure OnMyCommand to generate a progress bar for curl) that will explain what I am doing and why I am after only a regex pattern. I’m not actually coding in a language, per se…but configuring a tool to use a regex.

  • 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-05-11T16:31:54+00:00Added an answer on May 11, 2026 at 4:31 pm

    It looks like this is the best I can do:

    ^\s*([^ ]+)\s+([^ ]+)\s+(?:[^ ]+\s+){3}([^ ]+)\s+[^ ]+\s+([^ ]+)\s+
    

    I collapsed the matches you do not care about, made them not capture, and left off the unneeded trailing matches. If it is important to match everything (e.g. there are other lines that would match this) you can say:

    ^\s*([^ ]+)\s+([^ ]+)\s+(?:[^ ]+\s+){3}([^ ]+)\s+[^ ]+\s+([^ ]+)(?:\s+[^ ]){4}
    

    Note, my changes also change the capture numbers:

    • $1: percent finished
    • $2: size uploaded so far
    • $3: size to upload
    • $4: average upload rate

    You may be able to get away with this if it supports \S

    ^\s*(\S+)\s+(\S+)\s+(?:\S+\s+){3}(\S+)\s+\S+\s+(\S+)\s+
    

    but it does not mean exactly the same thing.

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

Sidebar

Related Questions

I have this regex which some kind folks on SO helped me with yesterday.
peace folks, I have this small piece of jquery based code, that grabs all
So I have this function that forks N number of child processes. However it
Folks, I have this array: var list = new Array('Archer','Archer','Banker','Lantern','Toryboy','The Barb','Tim Whiffler','Glencoe','Warrior','Nimblefoot','The Pearl','The Quack','Don
Greetings folks. I have this weird problem. In the project I'm working on now,
Hi folks I have a map in my bootstrap.groovy, how can use this map
Hi folks i have this terrible problems i hope any of you could help
I've found various examples in jsf where folks have done this successfully; in these
hi folks I have this following code but it gives me invalid argument error
Curious whether folks have setup 2 way transactional replication on the tables ASP.NET uses

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.