简体   繁体   中英

extracting data from txt file?

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?

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

Use the following code:

( id=")[^"]*"

This will match any Id's value.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM