pomsky icon indicating copy to clipboard operation
pomsky copied to clipboard

Can pomsky provide a permutations operation?

Open pansila opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

It's cumbersome to list all permutation of anded patterns, this can be done as a sugar syntax in pomsky?

Describe the solution you'd like

In pomsky: 'fox' & 'dog' In regex:.(?:fox.*?dog|dog.*?fox)

Describe alternatives you've considered

Not yet

Additional context

No

pansila avatar Feb 19 '23 15:02 pansila

I wouldn't call this an 'and' operation. You can think of regular expressions as sets, and | creates the union of two sets. Logically, & would be the intersection of two sets, which is rarely useful.

I'm not sure if permutation deserves dedicated syntax, and if we decide to implement this, it won't use the & symbol. Available symbols are: ~@$%/-,<>

Aloso avatar Feb 19 '23 21:02 Aloso

Sure, what ever you call it is okay, I mean the need for this is real, it's useful to search a line with all patterns match no matter the order, like I want a line with both keywords of 'fox' and 'dog' in. Otherwise, I have to filter out all lines with 'fox' matched, then filter again over the results with 'dog' matched.

pansila avatar Feb 19 '23 23:02 pansila