Re: regex to add a variable to calls

2016-09-19 Thread Thierry Douez
2016-09-17 0:13 GMT+02:00
Dr. Hawkins :

I need to catch every instance of
>
> getVal(a,b,c)
>
> and change them to
>
> getVal(a,b,c,dbtr)
>
> (and similarly to find when called with one or two arguments)
>
> dbtr is the variable name I want to pass.
>


​Here is one way to do it.


*on* mouseUp

*put* "getVal\([^)]+(?=\))" into theRegex

*put* "\0,dbtr" into smartReplaceText

*if* sunnyreplace( fld "f1", theRegex, smartReplaceText, outText) *then*

*put* outText into fld "f2"

*end* *if*

*end* mouseUp

​

​some sample input text in fld "F1" :

get getVal(a)

put getVal(a,b) into z

put getVal(a,b,c) && getVal(a,b,c) into y


and results in fld "f2":

get getVal(a,dbtr)

put getVal(a,b,dbtr) into z

put getVal(a,b,c,dbtr) && getVal(a,b,c,dbtr) into y


Is this what you are looking for?

Regards,

Thierry
​



Thierry Douez - http://sunny-tdz.com
sunnYrex - sunnYtext2speech - sunnYperl - sunnYmidi - sunnYmage
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

regex to add a variable to calls

2016-09-16 Thread Dr. Hawkins
As I move to multiple open debtors, I'm having small but consistent and
numerous changes.

I need to catch every instance of


getVal(a,b,c)


and change them to

getVal(a,b,c,dbtr)

(and similarly to find when called with one or two arguments)

a can actually be a combination of letters and numbers (a variable
name)--but might be an expression to produce this.

b should only be empty or "D", "T", and one other like that, and c will be
a variable that evaluates to a number.

dbtr is the variable name I want to pass.

Even catching most, and inspecting before tapping replace, would be a huge
timesaver.

I don't remember enough regexes to make this work with the parens.

I'm thinking a search term of

getVal\(([a-z1-9A-Z]+,[a-z1-9A-Z]+,[a-z1-9A-Z]+)\)


and

getVal($1,dbtr)


as replace, but this isn't right.

Can anyone help?

Thanks
-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode