[Webchange-list] Search and Replace

Tim Hill tim at timil.com
Mon Jan 10 12:53:31 GMT 2011


In article <gemini.let2bc0014t4e03yo.vince at softrock.co.uk>, Vince M Hudd
<vince at softrock.co.uk> wrote:
> Tim Hill <tim at timil.com> wrote:

[Snip]

> > Naturally I turned to WebChangePro to add titles, and want to copy
> > the alt tag text in the process or the leafname if there is none.
>  
> > I have hit a brick wall in trying to do this as I can't see how to
> > include part of a found string in the replace string.
>  
> > I am sure I must be being thick: any pointers will be welcome. Please.

> It can indeed be done, but I'm sat at the wrong computer, on the wrong
> desk, in the wrong office. So, from memory, the way to insert a matched
> wildcard is to use an asterisk (for a multi-character wildcard)
> followed by its index number and a semi-colon to terminate that number.
> I *think* the index numbers start from 1, and there are a maximum of
> 99. Therefore, one of these should, I hope, do it:

> The simplest would be:

>  Replace: alt="*" 
> With: alt="*1;" title="*1;"

Your memory is slipping!  ;-)

I am very pleased to report that the second attempt worked:

Replace: alt="*" 
With: alt="*0;" title="*0;"

Brilliant! Thanks.

> If you want to ensure you're in the context of an image tag, then:

>  Replace: <img *alt="*"*> With:    <img *1;alt="*2;" title="*2;"*3;>

> The extra wildcards in that are to ensure anything else that may be
> between the img and alt or alt and > is maintained.

> The flaw in either of these, though, is that if you have any img tags
> that already have titles, they'll now have two.

Any that are already present are the same as exiting Alt tags anyway.
Phew.

> Another, slightly more crafty approach:

>   Replace: <img*alt*> With: <img*1;title*2;>

> Followed by running the alt text inserter. :)

> Or even avoiding wildcards altogether:

>   Replace: alt= With: title=

> Again, followed by the alt text inserter. Obviously, this last case
> assumes alt= doesn't appear anywhere else in your html.

In those cases, how would the original text find its way back 'into' the
Alt tag? 

Not to worry: I will use the first method as its drawbacks don't apply
here.

Thanks again.

T

-- 
Tim Hill
...................................................
                                            tjrh.eu



More information about the Webchange-list mailing list