[Shipped] Add "Trim" Binding Converter


#1

:muscle:Following feature has been shipped.
Find the related help center article here.
Find @Seb’s detail explanation on Custom Script Converter here


It’d be really nice to be able to “Trim” characters from the beginning and end of a binding.

For example, some API’s return image results with Image Source tags. You could cut these out to just obtain the image link in between the quotes. It’d be nice to be able to:

  • Trim X Characters from beginning of text

  • Tim X Characters from end of text.

  • Yes Please!
  • No thanks

0 voters


#2

Hi @AlexB,

Did you try to use the substring method of the text manipulation converter?

If that doesn’t suit your need, you can still use a Custom Script to truncate a text

Seb


#3

Hey Seb, actually the string length that I need varies, because the name of the image will vary. For example, I’m trying to extract the url from Item1: <img src-‘https://s3.amazonaws.com/domain.com/imagename1.jpg’/> and Item2: <img src-‘https://s3.amazonaws.com/domain.com/imagenamelonger2.jpg’/>

However, in my case if I could trim the first 10 characters from the beginning, and 3 characters from the end within one custom script, that would help a lot to extract the link. Right now I’m using one text converter to Find/Rplc the beginning tag, and then using another text item bound to the first with a Find/Rplc to remove the ending tag. Just not very efficient.


#4

Custom script should be your friend then :wink:

With the script below:

var t = INPUT.substring(10);
var t2 = t.substring(0, t.length - 3)
t2

#5

This is awesome! Thanks Seb.

I think we need an Intuiface post with a repository of all these custom scripts that can be used. They really help a lot!


#6

I second this!

There should be a section where a user should be able to share scripts or plugins/assets.

@bomee.lafitte

Is this possible?


Custom Script Converter: What can you do with it?
#7

@Seb is this possible? :wink:


#8

Also … regexps :slight_smile:

I’m awfully bad at it, but it works :wink:

Some input for those eager to learn more:


#9

@AlexB, @Louie_Smith, @bomee.lafitte: I think we should start a dedicated thread in the Tips - Best Practices section :wink:

@Alex: I hate regexp (coz I’m also bad at writing them) but they’re indeed the most powerful ones for such cases.

[EDIT]: Here’s the new thread to talk about the Custom Script