1. Pattern matching

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

new topic     » topic index » view message » categorize

2. Re: Pattern matching

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) 
new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu