Extract text between two strings

February 28, 2009 at 11:12:44
Specs: Windows XP
Hi, I would like to extract the text between two strings. These strings are on different lines. These texts do not occupy the whole line
-----------------------------
Example1

.

ReLI A\NCe

Mobile

Customer

Application Form (For IndividuaL)

111111 1 1111111 11111111111111 1111111111111111111111111111111 Customer

Information (PLEASE FILL IN

CAPITAL

LETTERS WITH

BLACK

INK) 2347307594 1. Name
-----------------------------
Example2
=

Mobile Postpaid

Customer

Application Form (For IndividuaL)

11111111111 1 1 11111111111 111 1 1111111111111 111111111111111111 Customer

Information

(PLEASE

FILL IN

CAPITAL LEITERS

WITH

BLACK

INK) 2347307572 1. Name
--------------------------------

What I need is to search for the number between "INK)" and "1. Name"

So output should give me 2347307594 and 2347307572 respectively.

Also, if possible I would like to rename the file with this information.


See More: Extract text between two strings

Report •


#1
February 28, 2009 at 13:35:57
If the string INK) only occurs in the lines of interest, try this.

=============================
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=2 delims= " %%a in ('find "INK)" ^< myfile') do (
echo %%a
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •
Related Solutions


Ask Question