Note that there are some explanatory texts on larger screens.

plurals
  1. POComparing collections of Reg Ex Patterns
    primarykey
    data
    text
    <p>In short how do I best check if two collections of Reg Ex Patterns are equal(ignoring order)?</p> <p>A bit more info on what i am actually trying to do with it, I have an object i use to filter log messages with, this filter object contains collections for each thing it can be used to filter on, one of those things are a Reg Ex Patterns. I have created a equals method for my filtering object so i can see if two filters are basically the same, for the other collections i can use the collections .equals method, but i have problem with the Pattern objects.</p> <p>I could keep a list of the string input for the patterns in a different list and compare the string lists with .equals or I could run all the objects through and check them one by one if there .toString matched something in the other list for each list like this:</p> <pre><code> boolean equals = true; for (Pattern p1: patternList1) { boolean found = false; for (Pattern p2: patternList2) { if(p1.toString().equals(p2.toString())) { found = true; break; } } if(!found) { equals = false; break; } } if(equals) { for (Pattern p1: patternList2) { boolean found = false; for (Pattern p2: patternList1) { if(p1.toString().equals(p2.toString())) { found = true; break; } } if(!found) { equals = false; break; } } } return equals; </code></pre> <p>This dos not look very effective but would work, but it would not catch if two of the regexp patterns matches the same but written different. How can the code above be optimized/done differently? and is there any "simple" way of catching reg ex that are written different but matches the same?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload