Re: regular express
- From: Chris Cole <ithinkiam@xxxxxxxxx>
- Date: Thu, 28 Apr 2005 13:10:59 +0100
On Thu, 28 Apr 2005 01:41:36 +0000, linda wrote:
> I have a string looks like:
>
> "hello, world! perl programming is
> great"
>
> How I can use substitute and regular express to replace multiple space
> to a single space, that is, make this string as:
>
> "hello, world! perl programming is great"
>
> Thanks in advance.
To avoid people treating this newsgroup as a script-writing service you
should always give examples of code you have tried when you post
questions.
However, as you seem to be newbie and I'm feeling generous here you go:
#!/usr/bin/perl
use strict;
use warnings;
my $line = 'hello, world! perl programming is
great';
print "$line\n";
$line =~ s/\s+/ /g;
print "$line\n";
BTW they are called regular expressions :-) Chris.
.
- References:
- regular express
- From: linda
- regular express
- Prev by Date: Re: mysql driver problem? (slightly off topic)
- Next by Date: Re: examples using Template::Plugin::Page
- Previous by thread: regular express
- Next by thread: Re: serial programming in Perl,
- Index(es):
Relevant Pages
|