How tu replace First symbol from string?

I need to extract only the first character from the phone number string as “0XXXXXXXXXXXXXXXXXXX”. The result should be “XXXXXXXXXXXXXXXXX”.

AI assistant suggested such a function:
{{substring(get(96.value; “externalNumber”); 0; indexOf(get(96.value; “externalNumber”); “0”))}}}
{{substring(get(96.value; “externalNumber”); add(indexOf(get(96.value; “externalNumber”); “0”); 1); length(get(96.value; “externalNumber”)))}}}

But this formula gives an error:
DataError
Failed to map ‘value’: Function ‘substring’ finished with error! Function ‘add’ finished with error! ‘0’ is not a valid array.

Can you please tell me what I can fix?

Hi @Dmitry_Poberezhny,

Since the value you interact with is of type String, you should use functions that work with strings.

You are using the substring function incorrectly, use it like this;

{{substring(1.value; 0; 1)}}

EDIT:
Sorry, I misunderstood. You want to omit the first character. You can use a text parser to omit the first character with the following regex pattern:

^.(.*)

Cheers,
Henk

4 Likes

Use regular expressions for that.

This should work: \b(\d)

When you match the regular expression, the result will contain the first digit.

That said, if you explain what you’re trying to achieve (beyond getting the first digit) there might be a better solution.

L

Thank you!
I got it working like this:

1 Like

You can also use {{ substring(1.value; 1) }}

Avoid wasting an operation unnecessarily.

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

1 Like