How do I extract all of the values returned using the Split method?

I have put a list of comma-separated numbers into a global variable. The list may consist of 2, 3 or 4 values. I need to be able to extract each of those values in order to compare it to the value stored in another variable. I have seen postings from 2016 saying that this function isn’t working–has it been fixed?


Yeah, I’ve not been able to get the split() method to work either.

My basic method is to use slice() to get only the target substring or value I need, e.g., MyString.slice(0, MyString.indexOf('TargetSub')). The slice() function does not alter the string, so if I need to actually extract and remove substrings, I then use substring() or replace() to remove the target substring. E.g., MyString.replace('TargetSub', '').

See this recent thread where I use a method to do this with a repeater and comma-delimited values. The basic formulas are at the bottom of the post.

Also, consider if you could use a simpler method of testing your global variable for the presence of a value without anything too fancy. Your condition would simply test If OnLoadVariable contains "TargetValue" and then you wouldn’t have to worry about any string functions. Of course, your values would have to be fully unique, so you couldn’t have “1” and “12” and test if it contains “1”. Rather, you’d need your values to be something like “001” and “012”.

Thanks for responding, @mbc66. Your last suggestion is similar to what I ended up implementing. I’d love if someone from Axure would give an official response–it’s hard to imagine that the Split function exists if there is no way to extract multiple values.

Not all functions are supported by Axure. String.split() is one of them. Another example is you can’t use RegEx in String.replace(), you can only match on a string. My guess is this lies in whatever interpreter they have built for their Axure syntax, it looks like JavaScript but it isn’t straight JavaScript, there’s an extra layer of interpretation in there for their Axure-specific stuff.

1 Like

Since Axure supports at least some of the String.replace functionality, it makes that they include it in the list of string functions. But String.split isn’t worth much if you can’t extract more than one value from it, so maybe I’m missing something. Still awaiting an official response.

You won’t get an array back from it, but can you supply the limit argument so that you can get back the first n values.

For example:
Will give you:

Personally I don’t think it’s very useful but from my experience over the years with Axure that’s the limit of what it does in Axure. Maybe I’ve missed something as well so I’d be happy to be wrong.

1 Like

Hi! Just hopping in quickly to confirm that as mbc66 and nkrisc mentioned, the .split() functionality will spit out the information but that’s about the extent of it; Axure RP doesn’t include the functionality to access that array further to use as you would normally. Their solutions hopefully help as workarounds.

Thanks for replying. There are better functions for doing what .split does, so I’ll stick with them. A true split function would be useful!

1 Like