>$str =~ m{ \A ( .{0,15} .*? ) \s }msx;
Yeah, this would do. I talked about the scenario where you didn't put "{0,15}",
but just "{15}". In that case, it wouldn't work if the value given in the
match string (15 as per above eg.) is greater than the character count of the
particular string
Mimi Cafe wrote:
From: John W. Krahn [mailto:jwkr...@shaw.ca]
Mimi Cafe wrote:
I used MySQL substr function to extra 100 characters from the result of a
query, but understandably, I don't get what I want.
Now I looked at Perl's substr function and it doesn't look like it can
help me achieve
Mimi Cafe wrote:
I used MySQL substr function to extra 100 characters from the result of a
query, but understandably, I don't get what I want.
Now I looked at Perl's substr function and it doesn't look like it can help
me achieve what I need to.
Let's say I have:
$s = "The black cat climbed th
Akhthar Parvez K wrote:
Hi Shawn,
$str =~ m{ \A ( .{15} .*? ) \s }msx;
I don't think this would work if the value given in the match string (15 as per
above eg.) is greater than the character count of the particular string. Right?
No, it will fail if $str is less than 15 characters. Try:
Hi,
> It works fine and I like it. My regex is not that good, but I can see what
> is doing. I modified it a bit (to capture up till a full stop sign).
Kewl. Good to hear that!
Regards,
Akhthar Parvez K
http://Tips.SysAdminGUIDE.COM
UNIX is basically a simple operating system, but you have to be
lto:akht...@sysadminguide.com]
Sent: 18 April 2010 15:45
To: beginners@perl.org
Subject: Re: Extract substring from offset to space or full stop
Hi Shawn,
> $str =~ m{ \A ( .{15} .*? ) \s }msx;
I don't think this would work if the value given in the match string (15 as
per above eg.) is gr
Hi Shawn,
> $str =~ m{ \A ( .{15} .*? ) \s }msx;
I don't think this would work if the value given in the match string (15 as per
above eg.) is greater than the character count of the particular string. Right?
Regards,
Akhthar Parvez K
http://Tips.SysAdminGUIDE.COM
UNIX is basically a simple ope
Mimi Cafe wrote:
$s = "The black cat climbed the green tree";
$substring = substr( $s, 1, 15); # this will return "The black cat c".
How can I have this return the whole word climbed rather than the c (i.e. I
need to get "The black cat climbed")? I need to get the remaining characters
from
Hi Mimi,
> How can I have this return the whole word climbed rather than the c (i.e. I
> need to get "The black cat climbed")? I need to get the remaining characters
> from the length till the next white space or end of a phrase.
> Any other way to overcome this limitation? How can I use regex he