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 8255759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:38:04+00:00 2026-06-08T01:38:04+00:00

I am pulling values from a string but I am having a problem removing

  • 0

I am pulling values from a string but I am having a problem removing certain character.

Mandrake 9.2 (32 bit)

the index I pull from returns that, but I want to remove the (32 bit) and its length and location differ from line to line in file. I used [0:-8] but the problem was the variance in strings, so I tried this in my code

lines = re.sub(' [\d.]*', ' ', plines2)

but did not succeed.

more lines:

Redhat 7.3 (32bit)

Redhat 8.0 (32bit)
Mac OS X 10.4
Home Premium (32bit)
Linux Ubuntu Desktop 9.10
Linux Ubuntu Desktop 9.10

They vary, I want to be able to remove the 32 bit part as well as the version so that only the product name is there, it appears not on all lines as you see, some come with version and bit version but some only with one or the other.

  • 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-08T01:38:06+00:00Added an answer on June 8, 2026 at 1:38 am

    Is this what you want?

    import re
    ss = 'Mandrake 9.2 (32 bit)'
    new_line = re.sub(r'\(.*?\)','',ss)  #'Mandrake 9.2 '
    

    Note that this only works if you’re guaranteed 1 set of matching parenthesis on a line…

    With a slight variation, we can make it work with all the the things you have above:

    new_line = re.sub(r'(?:\d+(?:\.\d+)*\s*)?(?:\(.*?\))?','',ss)
    

    This will match version strings number.number.number... It will also match anything inside parenthesis (inclusive). Each match will be removed from the line.

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

Sidebar

Related Questions

I'm having a problem with my explode function in PHP. I'm pulling a string
I am wrangling with a query pulling unique values from 3 tables. Is this
im pulling in images from the net, and want to manipulate them a bit
I am pulling values submitted from a form and displaying them in a couple
I'm working a program that is pulling a string field from an access database,
Clojures clojure.xml/parse, clojure.zip/xml-zip and clojure.contrib.zip-filter.xml/xml-> are excellent tools for pulling values out of xml,
I am pulling varchar values out of a DB and want to set the
I'm pulling data from an XML feed and manipulating it using the awesome SimpleXMLElement.
I'm pulling serialized data from a database along with an object type (where one
I'm pulling data from a calendar feed and each event in the calendar has

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.