[ale] regexp help

docx at io.com docx at io.com
Thu Sep 15 13:22:07 EDT 2005


On Thu, September 15, 2005 4:55 pm, David Hamm said:
> Hi,
>
> I need to move a number of .htm files to a Linux web server,  but the support
> image file names are all in random case and so are the src= tags.
>
> Can anyone tell me how to convert the case of the file name referenced in the
> following line.
>
> src="../images/XyZ.gif"  to src="../images/xyz.gif"
>
> I'm working with s/src\=\".*\"/ but don't know how to specify changing the
> case to lower in the replacement side of the regular expression.

You don't mention what you're using, but if you're using perl to process the
files, you can do something like the following. . .

  $lc_tag = lc($tag); $file =~ s/$tag/$lc_tag/g;

Then, for moving the image files and rationalizing the filenames, you can do
something like the following:

  for i in `\ls images/*.gif`; do
    j=`echo $i | tr 'A-Z' 'a-z'`
    mv $i $j
  done

-- 
Dylan Northrup - docx at io.com - http://www.io.com/~docx/
"Harder to work, harder to strive, hard to be glad to be alive, but it's
 really worth it if you give it a try." -- Cowboy Mouth, 'Easy'




More information about the Ale mailing list