2017-10-13 16 views
2

근무중인 여러 페이지에서 유효성 검사 문제를 해결하기 위해 노력하고 있습니다. 이 페이지가 마지막으로 검토 된 이후로 표를 코딩하는 올바른 방법은 을 </thead><tbody> 사이에 넣는 것입니다. 그 이후로 유효성 확인을 결정하는 권한은 <tfoot></tbody>을 거쳐야한다고 결정했습니다. 일부 페이지에는 이러한 테이블을 이동해야하는 수십 개의 테이블이 있습니다.Dreamweaver에서 RegEx를 사용하여 코드 조각 이동

</thead><tbody> 사이의 모든 것을 캡처하고 </tbody> 이후로 이동하는 방법이 있는지 궁금합니다. 나는 정규 표현식에 대한 기본적인 지식을 가지고 있지만 footer 내용을 찾는 방법을 알 수는 없다. 그리고 내용은 모든 바닥 글에서 동일하지 않습니다.

예 : 이것으로

<table class="table table-bordered text-right table-condensed mrgn-tp-lg"> 
<caption>Top 5 Pet Food Companies Worldwide in 2014, US$</caption> 
    <thead> 
<tr> 
    <th scope="col" class="active text-center">Company</th> 
    <th scope="col" class="active text-center">International Sales</th> 
    <th scope="col" class="active text-center">Sales in the EU</th> 
    </tr> 
</thead> 
<tfoot> 
<tr> 
<td class="small text-left" colspan="3">Source: Euromonitor International, 2015</td> 
</tr> 
</tfoot> 
<tbody> 
    <tr> 
    <td><b>1. Mars <abbr title="Incorporated">Inc.</abbr></b></td> 
    <td>$17.8 billion</td> 
    <td>$5.7 billion</td> 
    </tr> 
    <tr> 
    <td><b>2. Nestlé <abbr lang="fr" xml:lang="fr" title="Société Anonym">SA</abbr></b></td> 
    <td>$16.8 billion</td> 
    <td>$4.1 billion</td> 
    </tr> 
    <tr> 
    <td><b>3. Colgate-Palmolive <abbr title="Company">Co</abbr></b></td> 
    <td>$3.7 billion</td> 
    <td>$0.7 billion</td> 
    </tr> 
    <tr> 
    <td><b>4. Big Heart Pet Brand</b></td> 
    <td>$2.9 billion</td> 
    <td>Not available (N/A)</td> 
    </tr> 
    <tr> 
    <td><b>5. Blue Buffalo <abbr title="Company">Co</abbr> <abbr title="Limited">Ltd</abbr></b></td> 
    <td>$1.4 billion</td> 
    <td>N/A</td> 
    </tr> 
</tbody> 
</table> 

:

<tfoot> 
    <tr> 
     <td class="small text-left" colspan="6">Source: Mintel <abbr title="Global New Products Database">GNPD</abbr>, 2015.<br> 
     Note: rankings are based on 2014 data and <abbr title="Global New Products Database">GNPD</abbr> search was based solely 
     on products that contained a form of the word "flax."</td> 
    </tr> 
    </tfoot> 

그리고 기본적으로

<tfoot> 
    <tr> 
     <td class="small text-left" colspan="5">Source: Global Trade Atlas, 
     2015 <br> 
     Compound Annual Growth Rate (CAGR) </td> 
    </tr> 
    </tfoot> 

이 뭔가를 설정

<table class="table table-bordered text-right table-condensed mrgn-tp-lg"> 
<caption>Top 5 Pet Food Companies Worldwide in 2014, US$</caption> 
    <thead> 
<tr> 
    <th scope="col" class="active text-center">Company</th> 
    <th scope="col" class="active text-center">International Sales</th> 
    <th scope="col" class="active text-center">Sales in the EU</th> 
    </tr> 
</thead> 

<tbody> 
    <tr> 
    <td><b>1. Mars <abbr title="Incorporated">Inc.</abbr></b></td> 
    <td>$17.8 billion</td> 
    <td>$5.7 billion</td> 
    </tr> 
    <tr> 
    <td><b>2. Nestlé <abbr lang="fr" xml:lang="fr" title="Société Anonym">SA</abbr></b></td> 
    <td>$16.8 billion</td> 
    <td>$4.1 billion</td> 
    </tr> 
    <tr> 
    <td><b>3. Colgate-Palmolive <abbr title="Company">Co</abbr></b></td> 
    <td>$3.7 billion</td> 
    <td>$0.7 billion</td> 
    </tr> 
    <tr> 
    <td><b>4. Big Heart Pet Brand</b></td> 
    <td>$2.9 billion</td> 
    <td>Not available (N/A)</td> 
    </tr> 
    <tr> 
    <td><b>5. Blue Buffalo <abbr title="Company">Co</abbr> <abbr title="Limited">Ltd</abbr></b></td> 
    <td>$1.4 billion</td> 
    <td>N/A</td> 
    </tr> 
</tbody> 
<tfoot> 
<tr> 
<td class="small text-left" colspan="3">Source: Euromonitor International, 2015</td> 
</tr> 
</tfoot> 
</table> 
+0

가정을 통해서만 가능합니다. –

+0

그게 무슨 뜻입니까? – Ferkner

+0

HTML 컨텐츠를 안전하게 regex-replace 할 수 없습니다. 모호한 컨텍스트에서만 일치하려는 값을 알고있는 경우에만 정규식을 안전하게 사용할 수 있습니다. –

답변

0

당신은

(</thead>\s*)([\s\S]*?)\s*(<tbody>[\s\S]*?</tbody>) 

regex demo를 참조 사용할 수 있습니다. $1$3\n$2으로 바꾸십시오.

세부

  • (</thead>\s*) - 그룹 1 : </thead> 문자열 및 0+ 공백 (\s*)
  • ([\s\S]*?) - 그룹 2 : 어떤 0+ 문자, 가장 왼쪽까지 가능한 몇 가지로 이후 서브 패턴의 발생
  • \s* - 0+ 공백
  • (<tbody>[\s\S]*?</tbody>) - 그룹 3 :,515,
    • <tbody> - <tbody> 문자열
    • [\s\S]*? - 모든 문자 0+,
    • </tbody> ...의 좌단까지 발생 가능한 몇 작동 - </tbody> 스트링.

$1$3\n$2 후, 그룹 1의 값, 다음 그룹 3 값과 일치하는 대체 개행을 삽입하고 그룹 2 값.