Wildcards ???

Kay C Lan lan.kc.macmail at gmail.com
Mon Aug 26 22:53:13 EDT 2013


If you really want to do Search & Replace based on patterns, you could
write your own script in LC using matchText() but it would probably be
faster and easier to confirm that correct replaces were taking place if, on
OS X, you used the FREE TextWrangler & grep:

http://www.barebones.com/support/Textwrangler/updates.html

You'll be glad to know that this link takes you to where you can download
older versions, including PPC.

Write a simple script to repeat through all the objects of your stack and
if their script is not empty then output the object long name* and it's
script to a single file. Open in TextWrangler and a quick grep will have
all those replaces done in no time. Although it does have a 'Replace All'
option, when it comes to scripts and other important data I always step
through each and every replace - I'm always amazed how often there is a
case where it idenfies text to replace but it's the odd man out and I don't
want it replaced. The only gotcha, which I'm sure you're well aware of, is
that all those parentheses must be be escaped - standard grep stuff.

You could even write a simple script to read the amended file back into LC,
Repeat for Each Line, matchText(a line that clearly is an object long name)
then read in the script until you get to the next long name, then set the
script of the previous long name* to the lines you've just read.

* Not that you wouldn't do this, but more for any newbies reading; before
doing this, duplicate your stack, Close and Remove from Memory the original
stack, then do everything with the duplicate, then the long names will all
correlate correctly.

All pretty basic LC stuff for a man of your scripting talents :-)

HTH


On Tue, Aug 27, 2013 at 1:19 AM, Richmond <richmondmathewson at gmail.com>wrote:

> On 08/26/2013 07:34 PM, Jan Schenkel wrote:
>
>> See the documentation for the 'filter' command.
>> In its current incarnation, that command uses 'wildcard' expressions to
>> decide which lines to retain and which to discard.
>>
>>
>> HTH,
>>
>> Jan Schenkel
>>
>>   =====
>> Quartam Reports & PDF Library for LiveCode
>> www.quartam.com
>>
>>
>> =====
>> "As we grow older, we grow both wiser and more foolish at the same time."
>>  (La Rochefoucauld)
>>
>>
>>  ______________________________**__
>>> From: Richmond <richmondmathewson at gmail.com>
>>> To: How to use LiveCode <use-livecode at lists.runrev.com**>
>>> Sent: Monday, August 26, 2013 6:14 PM
>>> Subject: Wildcards ???
>>>
>>>
>>> "The find and replace was always using wildcards() even when Use Regular
>>> Expressions was false. The find
>>> stack has been updated to allow users to choose the type of search from
>>> Regular Expressions, Wildcards or
>>> Plain Text."
>>>
>>> What symbols must one use for a wildcard?
>>>
>>> Richmond.
>>>
>>>
>>>
> The reason I asked this question was because I had to do a socking great
> search and replace
> through about 5000 lines of code:
>
> Yes, you guessed it; Richmond's "Devawriter Pro" won't go away; it just
> gets bigger and groovier.
>
> Now I had all sorts of 'horrible' bits to search for and replace and
> Livecode didn't do "very well"
> (coded way of saying something fairly negative) with searching for phrases
> that had lines breaks in them.
>
> I ended up doing everything in LibreOffice (bloody-minded), which was OK
> as far as things went,
> but Wildcards weren't in it.
>
> Certainly I would like to be able to search for the following sort of
> phrase:
>
> set the unicodeText of the selected to ((numToChar(*)) & (numToChar(*)) &
> (numToChar(2325))
>
> in such a way that I can replace:
>
> ((numToChar(22345)) & (numToChar(66778)) & (numToChar(2325)) with
>
> ((numToChar(22345)) & (numToChar(66778)) & (numToChar(4444))
>
> and
>
> ((numToChar(99887)) & (numToChar(11223)) & (numToChar(2325)) with
>
> ((numToChar(99887)) & (numToChar(11223)) & (numToChar(4444))
>
> that is to say, that the wildcard bits remain unchanged.
>
>
> Richmond.
>
>
> ______________________________**_________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>



More information about the use-livecode mailing list