Regular Expression Queries for Expression Web

NB: Expression Web Queries are wonderful tools but they must be used with caution less you overwrite huge portions of your site that you didn't mean to.

*****ALWAYS make a backup before running queries****

To download a query

Right click the Download link for the query you wish to use (see below) in the browser (of choice) window, and choose  'Save Target As' or 'Save link as'. The message you see will depend on which browser you are using. Where it says 'Save in' (or locate in the folders pane in Vista) browse to the default location of queries in your version of Expression Web.

NOTE: Read our Expression Web Querys Tutorial for more information about how to run, write, share and save a query.

If you are purchasing the queries below, they are zipped for easy download, in which case follow the instructions in the welcome email you receive.

It is a good idea to get an general feel of what you are up against.

Download the following

First run the query: Find-any-tag-with-attribute-any-attribute-contains-any-value.fpq

This will show you ALL tags, however there will be many you don't want to remove.

Use this query merely to produce results which you can then sort by clicking the 'Matched Text' column header. (This will sort them into similar selections so you can 'read' the results more easily.) (see Expression Web Querys Tutorial)

IMPORTANT: This query is to be used as a tool ONLY, if you were to implement it you might lose things you don't want to like hyperlinks.

Note all the one's you want to get rid of. In my selection I have

table - border
td - width
b - bold
i - italic
u - underline
img - borders of varying values

So I shall certainly be using most of the query bundles. There are six bundles, plus the general find query above. If you have an idea for a query please contact us.

Fig 1 - Query folders

NOTE: When you have a lot of queries it can get untidy and be hard to find your query, so I suggest making a new folders in the Queries folder location I have entitled mine according to the bundle names e.g. Queries-table

 

Cleaning Query bundles

The TABLE CLEANING BUNDLE consists of 12 Expression Web Queries which will remove the following attributes.

$3.00

Whilst you might not always want to keep your tables as you should be moving to a div layout, you might need them in some situations for data tables.

  • align
  • bcolor
  • border
  • bordercolordark
  • bordercolorlight
  • cellpadding
  • cellspacing
  • class
  • height
  • id
  • style
  • width

The CELL TD CLEANING BUNDLE consists of 11 Expression Web Queries which will remove the following attributes *

$3.00

 

 The CELL TH CLEANING BUNDLE consists of 11 Expression Web Queries which will remove the following attributes *

$3.00
  • align*
  • bcolor*
  • bordercolor*
  • bordercolordark*
  • bordercolorlight*
  • class*
  • height*
  • id*
  • style*
  • valign*
  • width*

The BODY CLEANING BUNDLE consists of the following 12 Expression Web Queries which will remove the following attributes

$3.00
  • alink
  • background
  • bcolor
  • bottomargin
  • class
  • id
  • link
  • onload
  • style
  • text
  • topmargin
  • vlink

The TEXT TAG CLEANING BUNDLE consists of 5 Expression Web Queries 'b', 'strong', 'i', 'em' and 'u', either removal of 'b' and 'i' for 'strong' and 'em' or just the removal of 'i', 'b' and 'u'.

$3.00

The text tags of 'b', 'i' and 'u' for Bold, Italic and Underline are all now deprecated from the current specification . Instead one should have <strong> </strong> for 'b' = bold, <em> </em> for 'i' = Italic and u should now be used as a style using text decoration. It should NOT to be used to underline text within content as it can be mistaken for a hyperlink, it is best reserved for headings and side headings. More about text decoration - underline.

The MIXED CLEANING BUNDLE consists of 2 Expression Web Queries which include;

$2.00

The Font remove tag Query can find all the font tags with any attribute that contains any value and remove the tag and the attributes.

NOTE: It pays to run the query a few times as it finds different font selections to remove.

The Image remove border Query will find all img tags and remove the attribute border which contains any value, 1,2,3 etc.

The World Wide Web Consortium now regards the attribute 'border' as outdated. Newer constructs are recommended. Meaning you should have this style in your .css sheet which will set a value of 0px for every image within your site. Borders for images should be applied in your graphic editor of choice.

body img {

border: 0px;
}

The SUPER BUNDLE consists of all the above bundles

You can obtain each of the first five bundles for $3 and the Mixed Cleaning Bundle for $2, however if you buy the Super Bundle which consists of all six bundles you can buy it at the reduced cost of $15 thereby saving you $2.

$15.00

Free Expression Web Queries

  1. Add Title Attribute not including img or name - (See * below)
  2. Add Title Attribute not including img - This query does the same as #1 only it does not include within the search images (img) but does include bookmarks (name) within the search.
  3. Add Title Attribute - This query does the same as #1, however it does not include bookmarks and images within the search.

The Add title attribute with no img or name Query will find all 'a' tags excluding 'img' tag and 'name' tag and add a Title Attribute code

find and replace insert title.Fig 2 - To Pane *

This query runs a Find on all 'a' tags that do not have a Title Attribute, but excludes 'a' tags (hyperlinks) that are attached to a 'img' tag or a 'name' (bookmark) tag. After the query has run, you can then proceed to work through each link and there is no need to go to the page select the hyperlink and open the hyperlink dialog box and open the Screen Tip button or even insert your title attribute in code view. You can do it through the Find and Replace dialog box one link at a time.

After running the query select the first result, then select 'Current Page' observe what the hyperlink is about and in the 'To' pane merely type in what you want the Title Attribute to read. e.g. On our example graphic (See Fig 2) we have the sitepoint.com hyperlink so I have typed in the 'To' pane Sitepoint, then hit the 'Replace' button.

NOTE: Be very careful about what you are doing, you do NOT want ALL your hyperlinks to have a empty title attribute or worst all be inserted with text that's the same, so be careful NOT to select the 'Replace All' button. This is not an operation you do without focusing upon.

Firefox links without titles.If you want to double check your page you might like to use the Firefox web developer add-on. On the Outline menu - Outline Links - Links without Title Attributes, after you have selected this it will highlight any links on page that do not have a title attribute, if you don't see any you have found them all.

Find and implement

Finding all instances of xthumbnail-orig-image comment

find replace xthumbnail.The setting 'Tracing Image and Interactive Button attributes' is selected under 'Remove Generated HTML' on the 'Optimize HTML' Dialog box. (This setting is suggested when you follow the Setting up Expression Web EBook.) Which is run in 'Code View' by right clicking and select 'Optimize HTML' and this will remove any left over commenting code generated when you make a thumbnail in Expression Web. However, this can only be done on the page not globally. If you are in the habit of forgetting to remove this commenting code, you can verify your pages are clean by running a Find for xthumbnail-orig-image on all your pages. Just make sure you select 'Find in Source Code'. You can then run the 'Optimize HTML' dialog box in 'Code View' to remove each instance on each of the pages they appear on. Unfortunately I have been unable to devise a query that would remove these globally. Yet!