[ale] regexp help

David Hamm ale at spinnerdog.com
Thu Sep 15 13:49:56 EDT 2005


Outstanding!!  That did it.  Thanks Jason.
On Thursday 15 September 2005 01:17 pm, Jason Day wrote:
> On Thu, Sep 15, 2005 at 12:55:38PM -0400, David Hamm wrote:
> > 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 could use this:
>
> s/src="\([^"]*\)"/\Lsrc="\1"\E/g
>
> The \L in the replacement pattern means "convert everything to lowercase
> until you see a '\E'".  This works in sed and vi.  If you're using perl,
> omit the backslashes in front of the parentheses and change \1 to $1:
>
> s/src="([^"]*)"/\Lsrc="$1"\E/g
>
> Note that I changed your match pattern slightly.  The pattern you had,
> /src=\".*\"/, is likely to have unintended side effects, because it will
> do a greedy match.  For example, if your html has the following line:
>
> <img src="../Foo.GIF"> Blah blah blah Verbage, etc. <img src="../BAR.Gif">
>
> Then all the verbage between the two image tags would get lowercased as
> well, which is probably not what you want.
>
> HTH,
> Jason



More information about the Ale mailing list