cancel
Showing results for 
Search instead for 
Did you mean: 

How to fing duplicate values in a string

Former Member
0 Kudos

Hi All,

I am working on Visual Composer (NW2004s). I am having a String in form <b>AX:AX:BT:I</b> I want to find if AX and AX are same or not in that string with help of functions. Also I am not sure that lenegth of characters before ':' will be same every time. Can any one tell me solution for this.

regards,

sheetal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sheeetal,

I looked at the string functions available in Visual Composer (NW2004s). I think it is not possible to search for a specific string (i.e. for the ":" ). As you haven't the possibility of developing iterations, neither, I think you should use a BAPI or webservice therefore. I.e. pass the string AX:AX:BT:I to a BAPI and receive the result you want, for example "AX:BT:I" or "Double occurence of AX" or whatever.

Best Regards, Benni

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

Do you want to say that you want to check whether the 1st and 2nd value between ":" are same or not.

Thanks & Regards

Harsimran

Former Member
0 Kudos

Hi Harsimran ,

Yes . I want to check whether the 1st and 2nd value between ":" are same or not.

regards,

sheetal.

Former Member
0 Kudos

i'm not sure if it works, but you could try working with the Text Function AT(text,pos) if the 2 value's are a fixed locations within the string you should be able to do compare them within a formula

something like:

IF( ( AT(nameString,0) == AT(NameString,3)) && (AT(nameString,1) == AT(NameString,4),DoSomething,DoSomethingElse)

Former Member
0 Kudos

Hi sheetal

check out the following link

Then try to form formula.

The second option is make a web service and compare in it and then use it in VC.

Thanks & Regards

Harsimran

Former Member
0 Kudos

Hi Sheetal, hi Andre,

I thought about this possibility, Andre mentioned, too. But as Sheetal said, the length varies. Thus, you need a loop, which is not possible in VC.

However, you can extend the formula. If you are sure, that the length is between 1 and 3 characters, you can use the following <b>Pseudo-Syntax!!!</b>:

IF (character1 = character3) <i><-- case A:A</i>

OR IF ((character1 = character 4) AND (Charachter2 = character 5)) <i><-- case AB:AB</i>

OR IF ((character1 = character 5) AND (Character2 = Character6) AND (Character3=Character7)) <i><--case ABC:ABC </i>

Best Regards, Benni

Former Member
0 Kudos

Hi Sheetal, Benjamin, Harsimran

I missed the part of the changing length. i think benjamin's solution should work here. but i think you should add an extra check, this code for A:A also responds when on AAA:BBB because the first and third char are thesame.

IF ((character1 = character3) AND (character2 = ':')) <-- case A:A

OR IF ((character1 = character 4) AND (Charachter2 = character 5) AND (character3 = ':')) <-- case AB:AB

OR IF ((character1 = character 5) AND (Character2 = Character6) AND (Character3=Character7)AND (character4 = ':')) ) <--case ABC:ABC

Regards,

André