545
Views
8
Comments
Solved
Check if a value exists to String List
Question

Hello All,

I have a vaiable named "Test" which has random values with the  below format:

xxxx-xxxx-xxxx where xxxx are numbers (integer)

Also, i have an entity attibute named "GetDeltia_Status.Record.Deltia_Status.Deltio".

My request is to check if the GetDeltia_Status.Record.Deltia_Status.Deltio exists in Test variable, and if yes then to remove it.

So, i split the Test variable in string list to split the Test variable to the list with the below format

xxxx

xxxx

xxxx

Then i set a condition to search the GetDeltia_Status.Record.Deltia_Status.Deltio value if exists to Test. And if yes, i add a "ListRemove" to remove this position and value too. Finally, i set to Test variable the new value without the GetDeltia_Status.Record.Deltia_Status.Deltio (if of course the GetDeltia_Status.Record.Deltia_Status.Deltio exists)

Example

The Test variable has the value 1567-4323-6543.

The GetDeltia_Status.Record.Deltia_Status.Deltio has the value 4323.

The Test variable value must be changed to 1567-6543.


Unfortunately, executing the below action, the Test variable value is 4323. Where is my mistake? 



2016-04-22 00-29-45
Nuno Reis
 
MVP
Solution

My suggestion is that you take the element like you were doing, but in the final assignment instead of String_Split.List.Current.Value, you save 

String_Join(StringSplit.List,"-")

You can use Replace like Vincent mentioned: 

Replace(Test,GetDeltia_Status.Record.Deltia_Status.Deltio,"")

But beware that this will leave the separators. You can have it at the beginning, at the end or two consecutive in the middle. So probably you need a second replace for that...

Replace(Replace(Test,"-"+GetDeltia_Status.Record.Deltia_Status.Deltio,""),GetDeltia_Status.Record.Deltia_Status.Deltio+"-","")

This replace will deal with it, by removing the string and one separator next to it only once.

UserImage.jpg
George M

Nuno Reis wrote:


Replace(Replace(Test,"-"+GetDeltia_Status.Record.Deltia_Status.Deltio,""),GetDeltia_Status.Record.Deltia_Status.Deltio+"-","")


Thanks for your reply and advise!

Using your suggestion, there is an issue. Take a look to the below example

The Text has the values

Upon executing your suggestion, i select to remove the string 77777(the string with 5 digits) and  the Text changes to the below

Any advise on this pls?

2020-09-21 08-42-47
Vincent Koning

Why not use a TextReplace for this? Seems a lot easier to me

2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello George.

You are returning List.Current. That returns only one element.

You probably want to save a concatenation of the elements (String_Join does the reverse of String_Split)

UserImage.jpg
George M

Thanks both for your reply.

@Nuno i want to "replace" the Text with the List of Text excluding the GetDeltia_Status.Record.Deltia_Status.Deltio 


@Vincent Can you advise me how to implement your approach?

2016-04-22 00-29-45
Nuno Reis
 
MVP
Solution

My suggestion is that you take the element like you were doing, but in the final assignment instead of String_Split.List.Current.Value, you save 

String_Join(StringSplit.List,"-")

You can use Replace like Vincent mentioned: 

Replace(Test,GetDeltia_Status.Record.Deltia_Status.Deltio,"")

But beware that this will leave the separators. You can have it at the beginning, at the end or two consecutive in the middle. So probably you need a second replace for that...

Replace(Replace(Test,"-"+GetDeltia_Status.Record.Deltia_Status.Deltio,""),GetDeltia_Status.Record.Deltia_Status.Deltio+"-","")

This replace will deal with it, by removing the string and one separator next to it only once.

UserImage.jpg
George M

Nuno Reis wrote:


Replace(Replace(Test,"-"+GetDeltia_Status.Record.Deltia_Status.Deltio,""),GetDeltia_Status.Record.Deltia_Status.Deltio+"-","")


Thanks for your reply and advise!

Using your suggestion, there is an issue. Take a look to the below example

The Text has the values

Upon executing your suggestion, i select to remove the string 77777(the string with 5 digits) and  the Text changes to the below

Any advise on this pls?

2016-04-22 00-29-45
Nuno Reis
 
MVP

In your previous example, all blocks had the same size.

Do the split. it is easier than building the rest of the logic.

2019-03-19 12-24-07
Mariano Picco
 
MVP

Here's how I'd do this...

String split, spits out a Text Record List, if I'm not wrong. Iterate through that comparing each one to the Test string. If there's a match, List Remove that element. At the end, re-concatenate all remaining Text Records using a hyphen as a joiner. 

2019-03-24 20-44-19
Hugo Dias

Hi,


You have your answer already.

But as an alternative you could use some kind logic with regular expressions in your applications with Regex_Replace or Regex_Search actions from the Text extension.

For one of the cases you mention you can use:


Best regards.

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