1

How can I do this task automatically. I need to change source order of the divs, which has same id in above 100 pages.

I created an example:

This is default condition

<div class="identification">  <div class="number">Number 1</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 4</div> </div>
<div class="identification">  <div class="number">Number 5</div> </div>
<div class="identification">  <div class="number">Number 6</div> </div>
<div class="identification">  <div class="number">Number 7</div> </div>

I need it like this

<div class="identification">  <div class="number">Number 1</div> </div>
<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
<div class="identification">  <div class="number">Number 7</div> </div>
<div class="identification">  <div class="number">Number 4</div> </div>
<div class="identification">  <div class="number">Number 5</div> </div>
<div class="identification">  <div class="number">Number 6</div> </div>

Is the manual editing only option? I use Dreamweaver.

I have to do this change in HTML source permanently.


Edit: (it's just example)

The fix things are, total div are 7 and every container div has same class="identification"

Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852

4 Answers4

2

Breathe deep and start manual editing. Take pauses of 5 minutes on every 10 minutes to avoid that you get freaked out. You'll finish in a hour or two. At least, in less time than figuring the regex solution for this.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • @ I have to do in 100 - 150 files and source of files are very poorly formatted. I want to do like just open the file and play any macro/regex etc. but if no shortcut then will do manually. – Jitendra Vyas Jun 02 '10 at 12:51
  • Yes I understand you. I've undergone the same horror. That's what you get paid for. – BalusC Jun 02 '10 at 12:54
  • @OP: either you parse the HTML and swap, or you do it by hand. As BalusC said, do it by hand: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – ANeves Jun 02 '10 at 13:12
1

The easiest solution would be to do a single Find & Replace, searching for the entire menu as it is now, and replacing it with the entire menu as you want it to be. This ignores completely the actual changes ("I want to move this div up here and that one down there"), and gets the job done in one operation, covering all 100 pages.

Alternatively, you can do several smaller Find & Replace operations:

Replace <div class="identification"> <div class="number">Number 3</div> </div> with <div class="identification"> <div class="number">Number 6</div> </div>

Replace <div class="identification"> <div class="number">Number 2</div> </div> with two lines:

<div class="identification">  <div class="number">Number 3</div> </div>
<div class="identification">  <div class="number">Number 2</div> </div>
VoteyDisciple
  • 37,319
  • 5
  • 97
  • 97
0

Well you could move it around using javascript, or you could delete list and replace it using javascript as well.

You can use jQuery detach(), remove() and append()/appendTo() methods for this kind of manipulation.

mr.b
  • 4,932
  • 11
  • 38
  • 55
  • Sorry, it's not clear from your question that you have to change it in source code. That's a different story then. – mr.b Jun 02 '10 at 12:40
0

is it always the same number you need to replace? In dreamweaver you could do a find and replace in all files in a folder. Replace "Number 6" with "Number X" then replace "Number 4" with "Number 6" then finally replace "Number X" with "Number 4"

saves you writing a program to do it

DrLazer
  • 2,805
  • 3
  • 41
  • 52