manuel.a.gonzalez.5494 0 Newbie Poster

I was wondering how could I solve this problem, I have a php project in which I have tables, but I didn't use <thead> and <tbody>, but now I am using DataTable jquery plugin, and it needs that the tables have them, so I need to modify all of my files, so I tried to do it with gsed but it doesn't seem to recognize the pattern because I have spaces and newlines between the elements I specify in my regular expression. For example

<table id="tableId" cellpadding="0" cellspacing="0" border="0" class="display" width="100%">
                            <tr>
                                <th>#</th>
                                <th>Nombre</th>
...
                            </tr>

So my plan is to search for the <tr> and <th> and any whitespace character between them and then insert the <thead>before that pattern, but when I write the regular expression it doesn`t match anything. This is the regular expression I am using

gsed -i '/<tr>[:space:]*<th>/i \\t<thead>' *.php

if I only use <tr>[:space:] then it matches so I think it is due to new line character but I am not sure

Note: I am using Mac OS X mountain lion and gsed version of macports