0

I am having a file say text.txt having similar blocks of patterns like

<tr> I am nitesh goyal <\tr> nothing nothing <tr> I logged in stackoverflow<\tr> nothing nothing <tr> I want help to solve this <\tr> anyhting anything.

I want to take all the blocks data<\tr>.

currently i am using the regexp

I stored the file in a variable buffer
regexp "tr.*?\\tr" $buffer

But it is giving only fist block. How to take all the blocks present with the same delimiter.

Is it possible to have one block at a time and do some operations and then take second and so on.

Sumit
  • 1,953
  • 6
  • 32
  • 58
  • Is that an attempt at HTML? Your tags aren't matched and `\\` does not belong in the terminating tag. – Marc May 04 '12 at 14:22
  • yes i am attempting to do some operations on html file. i stored the file in a variable and want to do some operations on particular blocks – Sumit May 04 '12 at 14:27
  • I think the answer to [this](http://stackoverflow.com/questions/3369458/how-do-i-extract-all-matches-with-a-tcl-regex) question might do the trick – Deruijter May 04 '12 at 14:34

1 Answers1

3

Use -all -inline options. In this case regexp command will return the list of all blocks it found.

set list_of_found_blocks [regexp -all -inline -- "tr.*?\\t" $buffer]
GrAnd
  • 10,141
  • 3
  • 31
  • 43