two easy ones

is there a string wild card

for something line this


set foo to {"abc", "cde", "efg"}
set theline to every item in foo contains "a*c"

I hope this would return “abc”

also is there a wasy to search on this site to make sure I’m not asking the same question someone else has ?

Unfortunately, no. I think that the Satimage.osax’s Text Additions suite will deal with regex, however.

Just below the big MacScripter blue banner there is a row of links. Search is just to the right of center.

mcgrailm,

I don’t think you’d want to use this for multiple wildcards, but an easy solution may be to use:

set foo to {"abc", "cde", "efg"}

set theline to {}
repeat with anItem in foo
	if anItem begins with "a" and anItem ends with "c" then set end of theline to anItem
end repeat

theline

and some followup reading:
http://bbs.applescript.net/viewtopic.php?id=14671

-N

hmm interesting I’ll have to play around with that I did find a completing differnt solution

Here’s one that doesn’t care how many characters are in between but doesn’t insist on first and last or the order


set foo to {"abjklc", "kac", "cab"}
set P to {}
repeat with I in foo
	set x to {offset of "a" in I, offset of "c" in I}
	tell x to if (item 1) * (item 2) ≠ 0 then set P's end to contents of I
end repeat
--> {"abjklc", "kac", cab}

And another that pays attention to order:


set foo to {"abjklc", "kac", "cab"}
set P to {}
repeat with I in foo
	set x to {offset of "a" in I, offset of "c" in I}
	tell x to if (item 1) * (item 2) ≠ 0 and (item 1) < (item 2) then set P's end to contents of I
end repeat
--> {"abjklc", "kac"}

and changing the tell x line like this, insists that there be at least one character between a and c

tell x to if (item 1) * (item 2) ≠ 0 and ((item 1) + 1) < (item 2) then set P's end to contents of I

Adam,

Where there’s a will, there’s a way!

-N