Forum: Ruby Re: Premature end of regular expression with non-ascii chara

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
67bb4df2775f6a6b603347dce7119571?d=identicon&s=25 unknown (Guest)
on 2006-01-31 19:57
(Received via mailing list)
Dear Nick,

I'm glad things finally worked out for you.
Actually, I things like '\352' do not to split any further (at least on
my
system (cygwin 6.7.0.0-6) on Windows XP),
this seems to be some  encoding for "ê" etc. that is  Windows-specific.
In particular, it is not equivalent to a string composed of '\',
'3','5','2'
(you would have to double the '\' in the regexp if you were searching
for a string '\352' in a text).

But the line

splitted_text=text.split(/(?=.)/)

should produce an Array with the individual letters in the string.
That involves a concept about regexps called zero-width positive
lookahead (see _http://www.regular-expressions.info/lookaround.html_
(http://www.regular-expressions.info/lookaround.html) ).

Please let us all know if you still encounter  problems.

Best regards,

Axel
E34b5cae57e0dd170114dba444e37852?d=identicon&s=25 Logan Capaldo (Guest)
on 2006-01-31 21:07
(Received via mailing list)
On Jan 31, 2006, at 1:56 PM, Nuralanur@aol.com wrote:

> (you would have to double the '\' in the regexp if you were searching
>
> Please let us all know if you still encounter  problems.
>
> Best regards,
>
> Axel

Zero width positive lookahead is a little overkill, split(//) works
just as well, AFAIK
This topic is locked and can not be replied to.