how to find string using wild card?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adeam
Posts: 17
Joined: Tue Dec 14, 2010 8:40 am

how to find string using wild card?

Post by adeam » Tue Feb 08, 2011 12:08 am

Hi,

I am new and would like to know how can I find in the field using a wild cards, such as * or ?. (In other program, * is equivalent to any characters or number in any numbers and ? is equivalent to any char or number for 1 character.)

For example, I would like to find string in field Filenames ending with -en.doc or docx under any subfolder name. My command is shown below but I believe, it is not correct.

Code: Select all

find string "/*/*-en.doc?" in field "Filenames"


What would be the right command?

Thank you.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: how to find string using wild card?

Post by jmburnod » Tue Feb 08, 2011 9:00 am

Hi adeam,
You can use the filter command
Something like that

Code: Select all

on getStringEnding
   put fld "filenames" into tCont
   put ".doc,.docx" into theEnding
   repeat for each item MyEnding in theEnding
      put tCont into tCont2
      put "*"&MyEnding into MyFilter
      filter tCont2 with MyFilter
      put tCont2&return  after tFound
   end repeat
   put tFound 
end getStringEnding
Best
Jean-Marc
https://alternatic.ch

adeam
Posts: 17
Joined: Tue Dec 14, 2010 8:40 am

Re: how to find string using wild card?

Post by adeam » Thu Feb 17, 2011 4:09 pm

Thanks Jean-Marc. I was away for quite sometime and almost forgot what I post. But now, I'm back. :D Thanks again.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: how to find string using wild card?

Post by jmburnod » Thu Feb 17, 2011 5:09 pm

Hi Adeam,

Congratulation you can live without Livecode :wink:

Jean-Marc
https://alternatic.ch

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: how to find string using wild card?

Post by BvG » Thu Feb 17, 2011 6:48 pm

A more powerful command is the matchChunk, giving you almost full regexp.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Linh
Posts: 16
Joined: Sun Mar 27, 2011 2:46 pm

Re: how to find string using wild card?

Post by Linh » Wed Mar 28, 2012 5:12 am

Thanks BvG, matchChunk is really nice.

Post Reply