0

Extract data from a text file, the file consists of the following, say:

<img src="a.jpg" alt="abc" height="12px" width="12px">
<div class="ab3" id="1122">
<img src="b.jpg" alt="abc" height="12px" width="12px">
<div class=cd5" id="9876">

I want to extract the "id" value from the above shown text file... the output should be:

1122
9876

I tried using findstr, find etc(DOS-COMMANDS), but not able to find the perfect regular expression for the same,

any other way is there, any help?

Aman Chawla
  • 304
  • 3
  • 8
  • 23
  • Try using winGrep: http://stackoverflow.com/questions/87350/what-are-good-grep-tool-for-windows – izogfif Feb 25 '13 at 11:57

2 Answers2

0

I agree with @izogfif, you should consider some other tools for this task.

But, to answer what you asked for, I got this regex:

id="[0-9]+"

It will give you output like this:

id="1122"
id="9876"

From there you can save those results (or use a pipe, however you do that in DOS), and then this regex:

[0-9]*

Will give you this output:

1122
9876
Cargo23
  • 3,064
  • 16
  • 25
  • thankyou sir, how should i use findstr....means i used t as findstr regularexpressiontobeplacedhere "filename"..........how should i use regular expression here – Aman Chawla Feb 25 '13 at 12:22
0

Use the following code:

( id=")[^"]*"

This will match any Id's value.

You can replace id with any attribute you are searching for.

Tiago Sippert
  • 1,324
  • 7
  • 24
  • 33
Bobby
  • 1