Get items on index number x of .split()

Anyone an idea? I’ve tried with (xx.split(’ ‘,2))[1] and xx.split(’ ',2)[1] - no useful results. It seems like that Axure has some problems with the [] brackets…

how do you try? where do you try? axure-internal? axshare-widget? own js-file? how do you set up the coding environment?

i don’t think axure internal arrays work. in axshare it should not be a problem to split axure-variables. if its you js you work in a common jquery environment with all options + axure functionset as far it can be used with data-label, axquery or known id.

1 Like

Not a good solution to test with AxShare. Preview is such a great feature…

Thanks!

I have the same issue and really don’t like to involve javascript into my solution.

My Goal
Perhaps not quite the goal of a wireframe, but I wanted to re-create a GET-method search form based on OnLoadVariable. So I set the OnLoadVariable to “VAR1=result1&VAR2=result2&VAR3=result3”, and reloaded the current page on that. Also, I do not want to create Global Variables for each possible field-input, keeping the max 25 globals in mind.

For splitting the variable into seperate results I used the split(‘&’), giving me “VAR1=result1,VAR2=result2,VAR3=result3”, which really didn’t improve the situation since now I just replaced ‘&’ with ‘,’ since I could not target the results.

My Solution
I could solve the issue though, using both replace and split-limit:
Getting the first var/result combo:
[[OnLoadVariable.split(‘&’,1)]] = “VAR1=result1”
Second var/result combo:
[[OnLoadVariable.split(‘&’,2).replace(OnLoadVariable.split(‘&’,1)+‘,’ , ‘’)]]
Any other var/result combo:
[[OnLoadVariable.split(‘&’,N).replace(OnLoadVariable.split(‘&’,N-1)+‘,’ , ‘’)]]

As you can see, a complex way of finding an array-like item, but it works. I was wondering if I missed something obvious ?

I am trying to get split working using the square bracket array accessor [0] eg .split(‘whatever’)[0]

I am just using split via the function editor on an on-click button.
works: [[LVAR1.split(’-’)]] (but of no use!)

doesn’t work: [[LVAR1.split(’-’)[0]]]

I’ve put together this demo to show how it doesn’t work:

Untitled Document

split.rp (70.3 KB)

Anyone shed any light?

Unfortunately I don’t think anything’s changed since a year ago when this thread was originally posted. It appears you can’t use bracket notation in Axure expression to access array indices.

Could be a case where instead of dynamically parsing data, you need to set up a predetermined scenario to demonstrate the feature.

it’s not just [ ] bracket notation, you also can’t chain functions. For example this also does not work:


[[LVAR1.split('-').shift()]]

Hi Meirion,
Try this,
[[LVAR1.split(’-’,0)]] > result is no
[[LVAR1.split(’-’,1)]] > result is bob
[[LVAR1.split(’-’,2)]] > result is bob, john
[[LVAR1.split(’-’,3)]] > result is bob, john , sue

Thanks,
Vikram

1 Like

Thanks Vikram, I’ll try that.

Making a Game in Axure? Simple and Modular Collision Detection

that might be a chance to vaidate the existance of a value inside an array.

GetArrayElements.rp (51.6 KB)

Here’s an ugly solution, hope this helps.

The js is beyond me - the Rita-Sue-Bob cultural reference less so. :wink:

Glad someone knows their films :smiley:

You can chain functions, I just think .shift() is not supported by Axure. If you click the “Insert Variable or Function…” in the fx (function) window when editing an expression you can see all methods you can use in Axure.

I have a “complex” way, but it works. The methods below:

[[someString.split(‘SEPARATOR’,INDEX).substring(someString.split(‘SEPARATOR’,INDEX).lastIndexOf(‘SEPARATOR’)).replace(‘SEPARATOR’,’’)]]

wish axure 9 can optimize this function…

Here’s a simple way in axure 9:

Items string:
Tencent,Alibaba,Huawei,Xiaomi

Get 1st item:
[[LVAR.split(’,’, 1)]]
// returns Tencent

Get 2nd item:
[[ LVAR.slice(LVAR.split(’,’, 1).length+1).split(’,’, 1) ]]
// returns Alibaba

Get 3rd item ( as same as above but different index number )
[[ LVAR.slice(LVAR.split(’,’, 2).length+1).split(’,’, 1) ]]
// returns Huawei

Get 4th item ( as same as above but different index number )
[[ LVAR.slice(LVAR.split(’,’, 3).length+1).split(’,’, 1) ]]
// returns Xiaomi