2262
Views
2
Comments
Solved
How to remove a certain part of a string?
Question

Hello,

I need some help on how to remove everything from a string if a substring finds a "," for example

Test 11/2019, nº 3 I want this result, Test 11/2019 In this case everything after the "," and the "," must be removed. How can I get this result? I tryied substring but it only removes the ","


UserImage.jpg
Gabriel Cardoso
Solution

Hey,

Something is not right here, the behavior that you describing is the Replace function and not the Substr

Anyways, to achieve that behavior, you can use 

Substr(String,0,Index(String,",") + 1)

if you always have a "," in your String.


Otherwise, it is better to use String_Split (dependency that you can add from the module Text), just because this always returns 1 value and you don't have to check if your string has a "," or not 


2016-04-21 18-13-58
Nuno Rolo
 
MVP

Hi Daniel,

You can use the Index function to know where the "," is.

Hope this help

UserImage.jpg
Gabriel Cardoso
Solution

Hey,

Something is not right here, the behavior that you describing is the Replace function and not the Substr

Anyways, to achieve that behavior, you can use 

Substr(String,0,Index(String,",") + 1)

if you always have a "," in your String.


Otherwise, it is better to use String_Split (dependency that you can add from the module Text), just because this always returns 1 value and you don't have to check if your string has a "," or not 


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.