1. Pattern matching
- Posted by axtens_bruce Jan 31, 2023
- 576 views
I recall there's some kind of pattern matching in Euphoria as well as regular expressions. I was wondering if it can be tweaked at all. For example, if I was looking for words that have the letters A E I O U in that order but without duplication. Duplications would be found with
*a*e*i*o*u*
for example 'adventitious', but if the asterisk could be configured to look only for consonants
patset("*","bcdfghjklmnpqrstvwxyz")
then the "*a*e*i*o*u*" would do the job.
I expect that someone's already thought about this and done it in a better way. I'm just thinking out loud.
-Bruce
2. Re: Pattern matching
- Posted by petelomax Feb 01, 2023
- 476 views
How about
?filter("abcdefghijklmnopqrstuvwxyz","in","aeiou")
(That's Phix, but pretty sure I nicked it from Euphoria)
Just for ideas, a decidely more Phix-only approach, which uses some features you can't have just yet, would be:
string az = "abcdefghijklmnopqrstuvwxyz", bz = az[2..$] for s in {az,bz} do ?scanf(s,"%sa%se%si%so%su%s") end for --output: --{{"","bcd","fgh","jklmn","pqrst","vwxyz"}} -- (az, pass) --{} -- (bz, fail)