cancel
Showing results for 
Search instead for 
Did you mean: 

Route to port 1 if output is string , to port 2 if output is number

Sahil
Contributor

Hi,
I have to route based on the output type using router snap.
Route to port 1 if output is string , to port 2 if output is number.
How to I do that? Thank you.

1 ACCEPTED SOLUTION

But if those numbers are between quote it means that it is string.

723456 and “723456” is not same.

See if this will help you to determine if it’s number or string.
$input.toString().match(/^\d+$/) != null ? true : false
This expression will check if value of input contains only numbers and if it is, then will return true, otherwise if not contains only numbers it will return false.
image

To check for string it’s opposite, you need to switch the places of true and false.
image

Regards,
Viktor

View solution in original post

6 REPLIES 6

bojanvelevski
Valued Contributor

Hi @Sahil,

You can include the ‘typeof’ function in a router snap. It will look something like this:

image

Regards,
Bojan

SpiroTaleski
Valued Contributor

@Sahil

Also in the Router Snap, you can use the instanceof global function that will return true/false if the given object is an instance of the given type.

ex: $input instanceof ‘String’

Regards,
Spiro Taleski

@viktor_n , Hi Viktor,
Any suggestions here.

Hi @Sahil,

Responses from @bojanvelevski and @Spiro_Taleski as I see are correct. Is there are problem with using them ?