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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:54:54+00:00 2026-05-26T17:54:54+00:00

How can I use Microsoft findstr to grep an item from a single line?

  • 0

How can I use Microsoft findstr to “grep” an item from a single line?

I’ve got a line that goes something like this:

<config>test</config><item>some data</item><date>2007-11-02</date><datestart>2007-10-31</datestart><path>d:\test\test\test.txt</path>

Now if I want to grep the content inside of <date> and </date> how would I write that regular expression?

One thing to note is that I will have to take the findstr command into a for-loop in order to grep the date and store it in a variable.

example:

for /f "Tokens=* Delims=" %%i in ('findstr /r /c:"regex" file.txt') do (
    set date=%%i
    set date=!date:-=!
)

Also, I don’t want to rely on tokens as they may vary.

  • 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-26T17:54:55+00:00Added an answer on May 26, 2026 at 5:54 pm

    We may use a trick to do what you want: after read the line in a variable, change <date> and </date> by a delimiter character that is not in the line (for example, $); then, just use a for /F "tokens=2 delims=$" to get the contents inside.

    set /P the_line=< file.txt
    set the_line=!the_line:^<date^>=$!
    set the_line=!the_line:^</date^>=$!
    for /F "tokens=2 delims=$" %%i in ("!the_line!") do set date=%%i
    set date=%date:-=%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I use the ListView_GetBkImage macro: http://msdn.microsoft.com/en-us/library/bb761246(v=VS.85).aspx ... from a C#/WinForms application? I
I'm aware that WCF RIA Services has a Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory that I can use to
I know that I can use WinDbg+PageHeap+ApplicationVerifier - Microsoft tools. I read there are
I need to implement the ISpeechPhraseElement so that i can use the AusioStreamOffset http://msdn.microsoft.com/en-us/library/ee125345(v=vs.85).aspx
Can I use Microsoft Development Studio (a.k.a. Visual C++ 6), but replacing its awful
In Microsoft Internet Explorer we can use Msxml2.DOMDocument.6.0 activeX component to do xslt based
We can use solr range query like: http://localhost:8983/solr/select?q=queryStr&fq=x:[10 TO 100] AND y:[20 TO 300]
You can use the Filter property of a BindingSource to do SQL like filtering.
I am trying to use Microsoft Kinect, for audio recognition. This is on a
How can I use Microsoft Access as a database in ASP.NET website? Is it

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.