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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:23:16+00:00 2026-05-26T01:23:16+00:00

I am a beginner with PYTHON and useless with regex and are struggling to

  • 0

I am a beginner with PYTHON and useless with regex and are struggling to replace an unknown number in a file with a new number. I have looked through the python how tos and examples for re but still can’t make any progress on how to create the expression.

# myfile.txt
Some text
More text
Option  "BlankTime" "15"
more text

I want to replace “15” with another number, this line only appears once in the file, but the line number it is on is unknown, and the value of 15 is also unknown and could be any number contained in the quotation marks.

Best way would be to do it with python ( re ?? ) but if that can’t be done then maybe sed ??

  • 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-26T01:23:17+00:00Added an answer on May 26, 2026 at 1:23 am

    It sounds like you’re looking for a particular parameter (BlankTime). This can be done with the following sed one-liner:

    cat myfile.txt | sed 's/\("BlankTime"\s*"\)[^"]*/\1987/'
    

    This’ll search for "BlankTime" and replace its value with 987, leaving all the other lines intact.

    edit To replace the contents of the file, use the following two-step approach:

    cat myfile.txt | sed 's/\("BlankTime"\s*"\)[^"]*/\1987/' > myfile.txt.tmp
    mv myfile.txt.tmp myfile.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A beginner's Python question: I have a string with x number of sentences. How
I'm a beginner in Python and have a file i've read in that has
As part of the last assignment in a beginner python programing class, I have
I am a beginner of python and have a question, very confusing for me.
I'm a beginner with both Python and RegEx, and I would like to know
Python beginner >>> import oauth2 Traceback (most recent call last): File , line 1,
I am a beginner with Python and trying few programs. I have something like
I am just a beginner in python. I have document score= {1:0.98876, 8:0.12245, 13:0.57689}
I'm a beginner in python and I'm trying to use a octal number in
I'm a python beginner, and I'm curious how can I send a dictionary through

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.