Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

regex help
Gidday all,

Im trying to write a regex to convert spaces to underscores and ampersands =
to 'and'  can someone help.

$safeString =3D "News & Events";
$safeString =3D~ s/&/and/g;
$safeString =3D~ s/\s/_/g;

Regards

Colin=20


This E-Mail is intended only for the addressee. Its use is limited to that
intended by the author at the time and it is not to be distributed without =
the
author's consent. Unless otherwise stated, the State of Queensland accepts =
no
liability for the contents of this E-Mail except where subsequently confirm=
ed in
writing. The opinions expressed in this E-Mail are those of the author and =
do
not necessarily represent the views of the State of Queensland. This E-Mail=
is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and del=
ete this message immediately.


Report this thread to moderator Post Follow-up to this message
Old Post
Colin Johnstone
09-24-04 08:56 AM


RE: regex help
I worked it out myself

$safeString =3D "News & Events";
$safeString =3D~ s!&!and!g;
$safeString =3D~ s!\s!_!g;

thank you
Colin

-----Original Message-----
From: Johnstone, Colin=20
Sent: Friday, September 24, 2004 3:32 PM
To: beginners@perl.org
Subject: regex help


Gidday all,

Im trying to write a regex to convert spaces to underscores and =
ampersands to 'and'  can someone help.

$safeString =3D "News & Events";
$safeString =3D~ s/&/and/g;
$safeString =3D~ s/\s/_/g;

Regards

Colin=20


This E-Mail is intended only for the addressee. Its use is limited to =
that
intended by the author at the time and it is not to be distributed =
without the
author's consent. Unless otherwise stated, the State of Queensland =
accepts no
liability for the contents of this E-Mail except where subsequently =
confirmed in
writing. The opinions expressed in this E-Mail are those of the author =
and do
not necessarily represent the views of the State of Queensland. This =
E-Mail is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and =
delete this message immediately.


--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Report this thread to moderator Post Follow-up to this message
Old Post
Colin Johnstone
09-24-04 08:56 AM


Re: regex help
On Fri, 2004-09-24 at 11:01, Johnstone, Colin wrote:
> Gidday all,
>
> Im trying to write a regex to convert spaces to underscores and ampersands
 to 'and'  can someone help.
>
> $safeString = "News & Events";
> $safeString =~ s/&/and/g;
> $safeString =~ s/\s/_/g;
>
> Regards
>
> Colin
>

What you have written is perfectly fine .. why do you think it will not
work ?
you may consider however writing '\&' instead of '&'

Bye
Ram




Report this thread to moderator Post Follow-up to this message
Old Post
Ramprasad A Padmanabhan
09-24-04 08:56 AM


RE: regex help
Hi!

what's problem in these regular expressions.. every thing correct!

do you need to convert one or more than one match into single replacement
then regexp should be

$safeString =~ s/\s+/_/g;




-----Original Message-----
From: Johnstone, Colin [mailto:Colin.Johnstone@det.qld.gov.au]
Sent: Friday, September 24, 2004 11:02 AM
To: beginners@perl.org
Subject: regex help


Gidday all,

Im trying to write a regex to convert spaces to underscores and ampersands
to 'and'  can someone help.

$safeString = "News & Events";
$safeString =~ s/&/and/g;
$safeString =~ s/\s/_/g;

Regards

Colin


This E-Mail is intended only for the addressee. Its use is limited to that
intended by the author at the time and it is not to be distributed without
the
author's consent. Unless otherwise stated, the State of Queensland accepts
no
liability for the contents of this E-Mail except where subsequently
confirmed in
writing. The opinions expressed in this E-Mail are those of the author and
do
not necessarily represent the views of the State of Queensland. This E-Mail
is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and
delete this message immediately.


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Report this thread to moderator Post Follow-up to this message
Old Post
Raymond Raj
09-24-04 08:56 AM


RE: regex help
Thank you I musthave just coded something wrong, your right they do =
work. Sorry!

-----Original Message-----
From: Raymond Raj [mailto:raymond@shafika.vetri.com]
Sent: Friday, September 24, 2004 3:55 PM
To: Johnstone, Colin; beginners@perl.org
Subject: RE: regex help


Hi!

what's problem in these regular expressions.. every thing correct!

do you need to convert one or more than one match into single =
replacement
then regexp should be

$safeString =3D~ s/\s+/_/g;




-----Original Message-----
From: Johnstone, Colin [mailto:Colin.Johnstone@det.qld.gov.au]
Sent: Friday, September 24, 2004 11:02 AM
To: beginners@perl.org
Subject: regex help


Gidday all,

Im trying to write a regex to convert spaces to underscores and =
ampersands
to 'and'  can someone help.

$safeString =3D "News & Events";
$safeString =3D~ s/&/and/g;
$safeString =3D~ s/\s/_/g;

Regards

Colin


This E-Mail is intended only for the addressee. Its use is limited to =
that
intended by the author at the time and it is not to be distributed =
without
the
author's consent. Unless otherwise stated, the State of Queensland =
accepts
no
liability for the contents of this E-Mail except where subsequently
confirmed in
writing. The opinions expressed in this E-Mail are those of the author =
and
do
not necessarily represent the views of the State of Queensland. This =
E-Mail
is
confidential and may be subject to a claim of legal privilege.

If you have received this E-Mail in error, please notify the author and
delete this message immediately.


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Report this thread to moderator Post Follow-up to this message
Old Post
Colin Johnstone
09-24-04 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:25 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.