Gossamer Forum
Home : General : Perl Programming :

small and simple question.

Quote Reply
small and simple question.
Hi,

I have a string that looks something like this.

$datastring = "~~Data1~~Data2~~Data3";

How can I search to see if the first 2 characters are "~~". If it is, remove them (only the first 2 "~~") from the string.

Thanks

Quote Reply
Re: small and simple question. In reply to
$datastring =~ s/^(~~)?(.+)$/$2/;

Happy coding,

--Drew
http://www.camelsoup.com
ftp://ftp.camelsoup.com
Quote Reply
Re: small and simple question. In reply to
Or....

Code:
$datastring =~ s/^~~//;
Installations:http://www.wiredon.net/gt/

Quote Reply
Re: small and simple question. In reply to
Or:

(index($datastring, '~~') == 0) and (substr ($datastring, 0, 2) = '');

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: small and simple question. In reply to
TIMTOWTDI, eh?

Happy coding,

--Drew
http://www.camelsoup.com
ftp://ftp.camelsoup.com
Quote Reply
Re: small and simple question. In reply to
Sure is Wink

Installations:http://www.wiredon.net/gt/