home about us contact us

free scripts advanced scripts online tools great books web related tutorials contributed tutorials news archive geek toys!

help forum live chat help

Selected article

RSS feed   enewsbar Live Subscribe    Add to MyYahoo    Add to Google

Other HTMLfixIT articles:

by Don

It is often necessary to replace the & character with the entity & to get validated (x)html. This clip will replace all appropriate ampersands excluding those that are part of defined character entities.

This one has a really really long line at the start, so what it may do with the pre tag to your browser is anyone’s guess.

; a clip to run a file looking for
; stray & characters that aren't part
; of   & etc type of special
; characters and replace them with &
; by Don Passenger
; email: don at
; comments welcome

^!SetWordWrap Off
^!Jump Doc_Start

; assign special characters to array
^!SetListDelimiter ";"
; super long line to follow
^!SetArray %allspecialchars%="&©>< " ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ—™™áâ´æàåãä¦ç¸¢¤°÷éêèðë½¼¾íî¡ì¿ï«¯µ·¬ñóôòªºøÕõö¶±£»®§­¹²³ßþ×úûù¨üý¥ÿ"
; end of super long line

; find next &
^!Find "&" TIS

; select 8 characters starting with an &
^!Jump Select_Start
^!Select +8

^!Set %word%=^$GetSelection$
;^!Info x^%word%x
; split the 8 characters selected on ;
; if there is no semi-colon, then we do
; not have a special character
; if we do, then we may
^!SetListDelimiter ";"
^!SetArray %specialchar%=^%word%

; if ^%specialchar0% is 1 then we had no ; so
; goto replacement phase
^!If "^%specialchar0%" = "1" Replace&

; we have a ; so we want to test the first part up to
; the ; to see if it is a known entity

^!Set %counter%=1
; if all specials exhausted, then need to replace
^!If "^%counter%" > "^%allspecialchars0%" Replace&
; test each special character and on match go to next
^!If "^$StrLower(^%specialchar1%)$" = "^%allspecialchars^%counter%%" MatchSpecial

; that one didn't match, try again
^!Inc %counter%
^!GoTo TestSpecials

; we found a loose & so we need to replace it
; with &
^!Jump Select_Start
^!Replace "&" >> "&" TIHS
; having replaced it go look for next
^!GoTo Loop

^!Jump Select_Start
^!MoveCursor +1
^!GoTo Loop

Keywords: replace, ampersand, &, &, replace, valid, html, xhtml, url

6 Responses to “HTML: Remove & and replace with &amp”

  1. wang Says:

    ,is quote, and comma’ ok? ‘ ,

  2. Best Painters Saskatoon Says:

    Great post and right to the point.
    Keep on sharing wonderful ideas.
    Best Painters Saskatoon

  3. Interior Designs Saskatoon Sk Says:

    Very interesting and well done.
    Interior Designs Saskatoon Sk

  4. Dentists Says:

    Keep sharing your great works. Always fascinated with this kind of content. I enjoy reading all your articles.


  5. bubble shooter game Says:

    This is a very interesting bubble shooter game with fabulous graphics,themes and the background scenarios!
    The player enjoys this interacting bubble shooter game because of the
    active role of the cute Pet Raccoon.
    Help to Pet Raccoon Mama to save all of her cubs.

    Combine 3 or more objects the same color for destroy a bubbles.

  6. Says:

    Hmm it looks like your site ate my first comment (it
    was super long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog blogger but I’m
    still new to everything. Do you have any tips and hints for
    rookie blog writers? I’d certainly appreciate it.

This site is totally free to use, you have absolutely no moral or legal obligations to help us continue.
There are however, some costs involved in running the site.

<random humor>
Plus we have nearly doubled in visitors in the past week, (We hope :-).
</random humor>

So if this site helped you find your way, perhaps you could consider contributing to our costs. Whatever amount you feel this site was worth to you would be just wonderful.
Use PayPal if you do decide to share and help us with the costs and in appreciation for our time and attention, or alternatively buy a book from our Bookstore..

  Time  in  Don's  part  of the world is:   March 2, 2024, 10:08 am
  Time in Franki's part of the world is:   March 2, 2024, 11:08 pm
  Don't worry neither one sleeps very long!

privacy policy :: support us :: home :: live chat help
contact us :: forum ::tutorials :: bookstore :: Site Map

      Valid XHTML 1.0!             powered by Apache Server
Pic 3 Pic 3


CIGHTML Firefox Thunderbird ClamWin WordPress SpyBot S&D TheGIMP Apache for Windows Registry Cleaners More cool stuff:


HTMLfixIT Site Stats.

Browser Statistics
Internet Explorer 85.88%
IE 717.63%
IE 62.3%
IE 50.00%
IE other8.6%
Moz Firefox 3.x3.03%
Moz Firefox 2.x0.18%
Moz Firefox 0.x/1.x26.65%
Netscape 8.x0.00%
NS 6+/Mozilla2.73%
Moz Seamonkey0.00%
Netscape 4.x0.00%
Opera 9.x0.00%
Opera 8.x0.00%
Opera 7.x0.42%
Opera 6.x0.00%
Opera other0.42%
Safari Mac/Intel5.21%
Safari Mac/PPC0.06%
Safari Windows25.2%
Google Chrome1.51%

Resolution Statistics
640 x 4800.25%
800 x 60026.14%
1024 x 76836.55%
1152 x 8640.25%
1280 x 80011.68%
1280 x 8540.00%
1280 x 102417.01%
1400 x 10500.00%
1600 x 12001.02%
1920 x 12007.11%
2560 x 10240.00%

OS Statistics
Windows 741.55%
Windows Vista2.4%
Windows 20033.91%
Windows XP20.86%
Windows 20000.36%
Windows NT40.05%
Windows 98/ME0.05%
Windows 950.00%
Mac OSX8.03%
Mac Classic0.00%

New Windows Virus Alerts
also by sophos.

17 Apr 2011 Troj/Mdrop-DKE
17 Apr 2011 Troj/Sasfis-O
17 Apr 2011 Troj/Keygen-FU
17 Apr 2011 Troj/Zbot-AOY
17 Apr 2011 Troj/Zbot-AOW
17 Apr 2011 W32/Womble-E
17 Apr 2011 Troj/VB-FGD
17 Apr 2011 Troj/FakeAV-DFF
17 Apr 2011 Troj/SWFLdr-W
17 Apr 2011 W32/RorpiaMem-A

For details and removal instructions, click the virus in question.