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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:22:00+00:00 2026-05-25T06:22:00+00:00

I wrote a file routing utility (.NET) some time ago to examine a file’s

  • 0

I wrote a file routing utility (.NET) some time ago to examine a file’s location and name pattern and move it to some other preconfigured place based on the match. Fairly simple, straightforward kinda stuff. I had included the possibility of minor transformations through a series of regular expression search-and-replace actions that could be assigned to the file “route”, with the intent of adding header rows, replacing commas with pipes, that sort of thing.

So now I have a new text feed that consists of a file header, a batch header, and a multitude of detail records under the batches. The file header contains a count of all detail records in the file, and I have been asked to “split” the file in the assigned transformations, essentially producing a file for each batch record. This is fairly straightforward, as well, but the kicker is, there is an expectation to update the file header for each file to reflect the detail count.

I do not even know if this is possible with pure regular expressions. Can I count the number of matches of a group in a given text document and replace the count value in the original text, or am I going to have to write a custom transformer for this one file?

If I have to write another transformer, are there suggestions on how to make it generic enough to be reusable? I’m considering adding an XSLT transformer option, but my understanding of XSLT is not so great.

I’ve been asked for an example. Say I have a file like so:

FILE001DETAILCOUNT002
BATCH01
DETAIL001FOO
BATCH02
DETAIL001BAR

this file will be split and stored in two locations. The files will look like this:

FILE001DETAILCOUNT001
BATCH01
DETAIL001FOO

and

FILE001DETAILCOUNT001
BATCH01
DETAIL001BAR

so the sticker for me is the file header’s DETAILCOUNT value.

  • 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-25T06:22:00+00:00Added an answer on May 25, 2026 at 6:22 am

    Regular expressions by themselves can’t count the number of matches they’ve made (or, better put, they don’t expose that to the regex user), so you do need additional program code to keep track of this.

    A regex can only capture text that exists somewhere in the source material, it can’t generate new text. So unless you can find the number you need explicitly at some point in the source, you’re out of luck. Sorry.

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

Sidebar

Related Questions

I wrote some mail merge code the other day and although it works I'm
I wrote a small executable in C# .NET that manages a .jar file. Our
I wrote a simple batch file as a PowerShell script, and I am getting
Jeff wrote about getting a file version/datestamp a while back. Visual studio doesn't increment
I wrote a program out, which was all in one file, and the methods
So I wrote buggy code that occasionally crash ... and creates a stackdump file.
I'm trying to write a log file from an ASP.NET application under IIS7, but
I'm trying to write a log file from an ASP.NET application under IIS7, but
I have an xml file which describes (among other things) elements with attribute values
So I wrote a parser routine to take one xml file and reparse into

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.