[ale] regexp help
    Jason Day 
    jasonday at worldnet.att.net
       
    Thu Sep 15 13:17:59 EDT 2005
    
    
  
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
-- 
Jason Day                                       jasonday at
http://jasonday.home.att.net                    worldnet dot att dot net
 
"Of course I'm paranoid, everyone is trying to kill me."
    -- Weyoun-6, Star Trek: Deep Space 9
    
    
More information about the Ale
mailing list