Remove characters between brackets in a string?

Does anyone know how to do the following on a widget with “set text”?

Change this:

Hello world (ha ha)

to this:

Hello world

I’m trying the following:

[[LVAR1.replace(/ ([^)]) */g, ‘’)]]

(where LVAR1 is the target)

But it’s not working (it seems not to parse it at all).

Unfortunately Axure only allows variables or sting literals to be used with replace() and not RegExp like you might expect. It would honestly make so many things much easier if we could. You could probably do something like this instead:

[[LVAR1.substring(0,indexOf(’(’))]] Assuming of course the parentheses are always going to be after the text you want to keep nor any text after you also want.

1 Like

Ah OK, thanks.

[[LVAR1.substring(0,indexOf(’(’))]] doesn’t seem to work for me - it just plonks all that into the widget as plain text. Is there something I’m missing?

the indexOf function needs to be tied to the LVAR1:



^ Thanks. Accidentally left that off.

1 Like

You’re welcome. You did the hard part of suggesting the solution :slight_smile:

Excellent - thanks! I need to get my head around how Axure works with this stuff.

Coincidentally, I’d just had a chat with somebody who was saying they liked to use Framer for prototyping b/c you can use JavaScript regexps into it when you need to. I said Axure did that too. But I now have apologise to her for lying :frowning:

I’m so rubbish at impressing girls.

1 Like

If you’re comfortable with JS you can do some really cool stuff very easily with Framer. I’ve played around with it and liked it. I certainly wouldn’t call it a replacement for Axure for everyone but what it’s good at is really cool.

Yes, I’d characterise Framer as a motion design prototyping tool, while Axure is an interaction design prototyping tool. Motion design is one of those things that’s a bit out of reach of most designers, and so gets left to libraries and the whim of engineers quite a bit. Framer addresses that quite well, although the level of JS you need it pretty high to make good use of it.

Which, at the risk of going even further OT, reminds of conversations I’ve had with devs about Axure. “Dude you could all that with just JS.” “Yes, but then I’d be working as a developer, not a designer.” It’s perhaps a subtle, but rather important, point!

This works great, but how do I get rid of the trailing space? e.g. “name (23)” becomes "name " and I really need it to be “name” (without the space).

You can use the trim function which removes spaces from the beginning and or end:

If there is always a space at the end, you can do this:
[[LVAR1.substring(0,LVAR1.indexOf(’ (’))]]

If you want to kill any spaces:
[[LVAR1.substring(0,LVAR1.indexOf(’(’)).replace(’ ‘,’’)]]

1 Like