Re: Expression Help



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.
.



Relevant Pages

  • Re: Read in XML File for input
    ... On 19 Oct 2007 at 12:04, Joseph L. Casale wrote: ... file to load in all the needed input I would require. ...
    (perl.beginners)
  • Re: Convert Scientific Notation to decimal equivalent
    ... Joseph L. Casale wrote: ... How can I match this specific pattern and convert it? ...
    (perl.beginners)
  • Re: Plymouth Config
    ... Joseph L. Casale wrote: ... That's what I have at which point it fails on booting and when ...
    (Fedora)
  • Re: Plymouth Config
    ... Joseph L. Casale wrote: ... it fails and asks me to scan. ... I scan and see its listed, and type it in manually and it boots? ...
    (Fedora)