Slice text with special characters

Apr 1, 2013 at 4:01pm

Slice text with special characters

Hi,

I want to slice a text, which includes special characters (like ö ü §) after every 8 characters.
Hi,my name is Ögiögi. – > Hi,my na me is Ög iögi

I tried atoi, which gives me a list with numbers, that I can split. Unfortunately some of the special characters have two numbers in the list. A reliable character slicing isn’t possible. Any ideas? Thanks!

#67462
Apr 1, 2013 at 7:59pm

if you’re not interested in re-combining the words later on (or if the special characters don’t matter) then you can simply filter out the extra characters:

the ASCII for umlaut ( ¨ ) is 195, so you could simply add a [zl filter 195] after [atoi], before splitting with [zl slice].

Otherwise you might need to check [regexp], but I’m not very experienced with it so I can’t help you there!

#242695
Apr 1, 2013 at 9:58pm

I want to recombine them later and the special characters mater :/ Hmm…

#242696
Apr 2, 2013 at 7:37pm

interessting problem. i tryed it with js and it has the same problem. for example it will report a string length of 4 for “ÖÖ”.
a regexp approach is (……..) and use outlet3 but how to get the remainding chars at the end which are less than 8?

#242697
Apr 3, 2013 at 2:49pm

this seems to work [regexp (..?.?.?.?.?.?.?)]
Get a list with the slices from outlet 3. O.

#242698
Feb 1, 2014 at 2:37pm

it seems like something has changed since then. js now gives me the correct string length, even with special characters included. O.

function string(arg)
{

var len = jsarguments[1] || 10;

outlet(0, arg.substring(0, len));
}

#279818

You must be logged in to reply to this topic.