Slice text with special characters

flocked's icon

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!

laonikoss's icon

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!

flocked's icon

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

11OLSEN's icon

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?

11OLSEN's icon

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

11OLSEN's icon

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));
}