lundi 29 juin 2015

Breaking a String Expression and Check for Duplicate


It's JavaScript.

I have a string which is a result of some process:

(A:x OR A:y) AND (B:m)

I want to check for duplication and mark it as duplicate even when the process results in

(A:y OR A:x) AND (B:m)

The process just changed the order of values for A.

P.S: Unfortunately this result is always a string and not some JSON type.

Question: What can be the most efficient solution to check for duplication for the pattern of string mentioned about. split(' ') might work but I am interested in the most efficient possible solution in JS.

  • same letters (e.g. A will have 'OR's b/w there values like 'x' & 'y'above)
  • different letters (e.g. A & B will have 'AND' between them)

Thanks a bunch for looking it.


Aucun commentaire:

Enregistrer un commentaire