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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:27:43+00:00 2026-05-11T11:27:43+00:00

I often find myself needing a tool that would allow me to: search for

  • 0

I often find myself needing a tool that would allow me to:

search for multiple multi-line regex patterns in a large file and replace them using back-referencing.

Should I:

  1. take the 2 hours it’ll require to build myself such a tool
  2. use something someone has already built (please suggest)
  3. learn to use a language that’s particularly good at this type of thing(Perl?)

Example
I have an xml document containing thousands of entries. There are about 100 entries with a known value field which need to be removed. I can build a regular expression for each entry. The expression is the same for the 100 entries except for the value string part. Either this tool would need to be able to loop through once for every value or just once with 100 OR terms (|) in the expression (it would be huge). In this case I’m replacing the matches with a blank but in other cases, I’d reformat the text and re-insert the value field.

  • 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. 2026-05-11T11:27:44+00:00Added an answer on May 11, 2026 at 11:27 am

    I reckon you should write the thing in Python. The python re library is great:

    # get the re library import re  # this is the line to process xml_line = '<stuff><bad i_am_naughty=\'True\'></bad></stuff>' # compile a regex  exp = re.compile ('(.*)(<bad.*bad>)(.*)') # run the regex on the line match = exp.search (xml_line) # print out the groups the regex found print match.groups () 

    N.B. You could also use python XML parsing libraries to strip out the elements you don’t want. Using the python XMl parsing simplifies some of the complexity that I have ignored in my example (multiple lines etc). In lieu of a Python XML parsing example this question has some good answers re parsing XML in Python.

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

Sidebar

Related Questions

I often find myself needing reference to an object that is several objects away,
I often find myself with a file that has one number per line. I
I often find myself wanting to scroll a Vim window so that the line
I often find myself reading books and articles that outline patterns, best practices, and
Often I find myself needing to write scripts that have to execute some portions
I find myself often needing to use int.TryParse() to test if a value is
I often find myself wanting to debug CSS layout issues that involve DOM changes
I often find myself with a list of disconnected Linq2Sql objects or keys that
I often find myself needing to write functions to load/save from/to ASCII (or similar)
I often find myself with fairly complex data that represents something that my objects

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.