String question

How to select substring:

from: "abcde *:; fghijkl mno pqrstuwxyz"

I want: everything between and icluding "cde" and "stu".
That is: "cde *:; fghijkl mno pqrstu"

Thanks!
GeekX [ Fr, 01 Juli 2005 22:26 ] [ ID #862936 ]

Re: String question

GeekX wrote:
> How to select substring:
>
> from: "abcde *:; fghijkl mno pqrstuwxyz"
>
> I want: everything between and icluding "cde" and "stu".
> That is: "cde *:; fghijkl mno pqrstu"

perldoc -f substr
perldoc -f index

> Thanks!

You're welcome.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ Fr, 01 Juli 2005 23:05 ] [ ID #862937 ]

Re: String question

GeekX wrote:
> How to select substring?

Do not multi-post!!
http://www.uwasa.fi/~ts/http/crospost.html

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ Fr, 01 Juli 2005 23:12 ] [ ID #862938 ]

Re: String question

In article <da48so$ivl$1 [at] phys-news1.kolumbus.fi>, GeekX
<no [at] email.presently> wrote:

> How to select substring:
>
> from: "abcde *:; fghijkl mno pqrstuwxyz"
>
> I want: everything between and icluding "cde" and "stu".
> That is: "cde *:; fghijkl mno pqrstu"

Easiest way would be (untested):

my $substring;
my $string = 'abcde *:; fghijkl mno pqrstuwxyz';
if( $string =~ /(cde.*stu)/ ) {
$substring = $1;
}


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jim Gibson [ Sa, 02 Juli 2005 01:22 ] [ ID #863776 ]

This looks like a bug to me

# In any case the string is not identical to the
# number 0 so for me this is a bug.

print 'Bug !' if 'bug' == 0;
George Bouras [ Mo, 04 Juli 2005 12:05 ] [ ID #865738 ]

Re: This looks like a bug to me

On 2005-07-04, George Bouras <bourasg.nospam [at] unisystems.gr> wrote:
> # In any case the string is not identical to the
> # number 0 so for me this is a bug.
>
> print 'Bug !' if 'bug' == 0;

No, it's not a bug, it's just the consequence of using a numeric
comparison on a string that doesn't begin with a digit.

I'm not sure where it is in the docs, but the camel has this:
""Improper conversions of a nonnumeric string like foo to a
number count as numeric 0; these trigger warnings if you have
them enabled, but are silent otherwise."

Essentially, it's just a result of the way converting a string to a
number is defined.

dha

--
David H. Adler - <dha [at] panix.com> - http://www.panix.com/~dha/
"I'll keep him as an insurance policy, since, unfortunately, I can't
kill him twice." - Scaroth
dha [ Mo, 04 Juli 2005 19:06 ] [ ID #865740 ]
Perl » alt.perl » String question

Vorheriges Thema: String Matching Question
Nächstes Thema: ps for windows