Re: Expression Help
- From: chas.owens@xxxxxxxxx (Chas. Owens)
- Date: Wed, 27 Feb 2008 15:24:43 -0500
On Wed, Feb 27, 2008 at 3:07 PM, Joseph L. Casale
<jcasale@xxxxxxxxxxxxxxxxx> wrote:
I am trying to replace all occurrences of a windows path such as "C:\Dir 1\Dir 2\Dir with more spaces" to a similar path, and have it case insensitive, and I can't make it work.
Anyone got an idea? I am hoping the syntax is compatible with Sed as my script has to be ran in two mode's, one being by hand with Sed :(
Thanks!
jlc
There are two ways (that I can think of off the top of my head) to
make a regex case insensitive: the i option and using character
classes:
$dir =~ s/C:\\Dir 1\\Dir 2\\Dir with more spaces/$newpath/i;
or
$dir =~ s/C:\\[Dd][Ii][Rr] 1\\[Dd][Ii][Rr] 2\\[Dd][Ii][Rr]
[Ww][Ii][Tt][Hh] [Mm][Oo][Rr][Ee] [Ss][Pp][Aa][Cc][Ee][Ss]/$newpath/;
I don't understand why you would run sed. Perl can be run from the
command line by hand as well.
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
.
- References:
- Expression Help
- From: Joseph L. Casale
- Expression Help
- Prev by Date: Re: How to read from keyboard?
- Next by Date: Re: Expression Help
- Previous by thread: Re: Expression Help
- Index(es):
Relevant Pages
|