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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:17:12+00:00 2026-05-27T04:17:12+00:00

A program creates HTML files from a database. There are headings and stuff in

  • 0

A program creates HTML files from a database. There are headings and stuff in between the headings.

There are not a set amount of headings.
After each heading the program places the text:

$WHITE*("5")$ 

$WHITE*("20")$ 
$HRULE$ 

I need every occurrence of these 4 lines to be replaced with:

$WHITE*("20")$ 
$HRULE$ 
$WHITE*("10")$ 

I am not fussed what program is used 🙂

I have tried:

sed 's:\$WHITE\*(\"5\")\$\n\n\$WHITE\*(\"20\")\$\n\$HRULE\$:\$WHITE\*(\"20\")\$\
\$HRULE$\
\$WHITE*("10")$:g'

and various other permutations

  • 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-27T04:17:13+00:00Added an answer on May 27, 2026 at 4:17 am

    UPDATE #2

    From the sed faq, section 4.23.3

    If you need to match a static block of text (which may occur any number of times throughout a file), where the contents of the block are known in advance, then this script is easy to use

    UPDATE #1

    Python?

    $ cat input
    first line
    second line
    3rd line
    $WHITE*("5")$
    
    $WHITE*("20")$
    $HRULE$
    some more lines
    yet another
    $WHITE*("5")$
    
    $WHITE*("20")$
    $HRULE$
    THE END
    

    the script:

    #!/usr/bin/env python
    
    ## Use these 3 lines for python version < 2.5
    #fd=open('input')
    #text=fd.read()
    #fd.close()
    
    ## Use these 2 lines for python version >= 2.5
    with open('input') as fd:
        text=fd.read()
    
    old="""$WHITE*("5")$
    
    $WHITE*("20")$
    $HRULE$
    """
    
    new="""$WHITE*("20")$
    $HRULE$
    $WHITE*("10")$
    """
    
    print text.replace(old,new)
    

    output:

    first line
    second line
    3rd line
    $WHITE*("20")$
    $HRULE$
    $WHITE*("10")$
    some more lines
    yet another
    $WHITE*("20")$
    $HRULE$
    $WHITE*("10")$
    THE END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Delphi program that creates HTML files. Later when a button is
I want to create Java program that creates certain HTML files and since they
I have a program that creates a JFrame and makes it visible. Is there
I imported the Software PAD File Database from http://paddatabase.net/download.html into Microsoft Access in a
I'm trying to parse an html output file from a program called mirdeep. I
Which editor adds this to the HTML files it creates? It is pretty obviously
I want to create a very simple HTML/AJAX based GUI for a Python program.
With win32api, I want that the following program creates two process and creates a
In Form1 I have PageControl. At run time my program creates tab sheets. In
use this website a lot but first time posting. My program creates a number

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.