Re: Wildcard? replaceText, offset?

2020-04-29 Thread Ben Rubinstein via use-livecode
Not sure what 'previous post' referred to. Reg ex "[0-9]+" (or equivalently 
"\d+") would match one or more integers.


Provided this is the first/only instance of the pattern, I would have thought 
that regex does provide the neatest solution, e.g.:


put "(" & iNewNumber ")" into tReplacement
put replaceText(tOldString , "\(\d+\)", tReplacement) into tNewString


On 26/04/2020 20:15, dunbarx--- via use-livecode wrote:

Pay no attention to the previous post, which only dealt with a single integer. 
Sloppy.
THIS old fashioned method works, though:
on mouseUpput offset("(",yourString) into startCharput offset(")", yourString) 
into endCharput random(999) into char (startChar + 1) to (endChar -1) of yourStringend mouseUp

Craig

-Original Message-
From: doc hawk via use-livecode 
To: How to use LiveCode 
Cc: doc hawk 
Sent: Sun, Apr 26, 2020 2:41 pm
Subject: Re: Wildcard? replaceText, offset?


On Apr 26, 2020, at 11:24 AM, Rick reasoned


In the middle-end part of the string I have “(x)” where x represents some 
integer.
it could be (4) or (10) or (5) etc.



If you’re certain that this is the only, or even the first, integer, a regular 
expression search and replace or [0-9]+  would  do the trick.


___
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


Re: Wildcard? replaceText, offset?

2020-04-27 Thread dunbarx--- via use-livecode
You are welcome.
Er, my offering IS a one liner.
Craig


-Original Message-
From: Rick Harrison via use-livecode 
To: How to use LiveCode 
Cc: Rick Harrison 
Sent: Mon, Apr 27, 2020 12:20 am
Subject: Re: Wildcard? replaceText, offset?

Thanks for the suggestions!

I was hoping that perhaps there was a very simple one liner or character that 
would do it for me.

I think I have a solution now.

Rick

> On Apr 26, 2020, at 3:15 PM, dunbarx--- via use-livecode 
>  wrote:
> 
> on mouseUpput offset("(",yourString) into startCharput offset(")", 
> yourString) into endCharput random(999) into char (startChar + 1) to (endChar 
> -1) of yourStringend mouseUp

___
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
___
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


Re: Wildcard? replaceText, offset?

2020-04-26 Thread Thierry Douez via use-livecode


> Le 27 avr. 2020 à 08:37, J. Landman Gay via use-livecode 
>  a écrit :
> 
> On 4/26/20 1:24 PM, Rick Harrison via use-livecode wrote:
>> In the middle-end part of the string I have “(x)” where x represents some 
>> integer.
>> it could be (4) or (10) or (5) etc.
>> I just want to replace the number inside the () with whatever other number I 
>> need to.
> 


   local T = "a(1)(z)(345)xxx(567Z33)(666)"

   if  sunnYreplace( T, "\((\d+)\)",  "(42)",  Tr ) then   put Tr

   --> a(42)(z)(42)xxx(567Z33)(42)



Thanks to check https://sunny-tdz.com/livecode/sunnyrex 


Thierry

___
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


Re: Wildcard? replaceText, offset?

2020-04-26 Thread J. Landman Gay via use-livecode

On 4/26/20 1:24 PM, Rick Harrison via use-livecode wrote:

In the middle-end part of the string I have “(x)” where x represents some 
integer.
it could be (4) or (10) or (5) etc.

I just want to replace the number inside the () with whatever other number I 
need to.


If there is only a single instance, you could:

  replace "(x)" with "(" & someNumber & ")" in myString

If there is more than one instance then each instance would need a unique character inside the 
parentheses.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com


___
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


Re: Wildcard? replaceText, offset?

2020-04-26 Thread Rick Harrison via use-livecode
Thanks for the suggestions!

I was hoping that perhaps there was a very simple one liner or character that 
would do it for me.

I think I have a solution now.

Rick

> On Apr 26, 2020, at 3:15 PM, dunbarx--- via use-livecode 
>  wrote:
> 
> on mouseUpput offset("(",yourString) into startCharput offset(")", 
> yourString) into endCharput random(999) into char (startChar + 1) to (endChar 
> -1) of yourStringend mouseUp

___
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


Re: Wildcard? replaceText, offset?

2020-04-26 Thread dunbarx--- via use-livecode
Pay no attention to the previous post, which only dealt with a single integer. 
Sloppy.
THIS old fashioned method works, though:
on mouseUpput offset("(",yourString) into startCharput offset(")", yourString) 
into endCharput random(999) into char (startChar + 1) to (endChar -1) of 
yourStringend mouseUp

Craig

-Original Message-
From: doc hawk via use-livecode 
To: How to use LiveCode 
Cc: doc hawk 
Sent: Sun, Apr 26, 2020 2:41 pm
Subject: Re: Wildcard? replaceText, offset?


On Apr 26, 2020, at 11:24 AM, Rick reasoned

> In the middle-end part of the string I have “(x)” where x represents some 
> integer.
> it could be (4) or (10) or (5) etc.


If you’re certain that this is the only, or even the first, integer, a regular 
expression search and replace or [0-9]+  would  do the trick.
___
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
___
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


Re: Wildcard? replaceText, offset?

2020-04-26 Thread dunbarx--- via use-livecode
Or, more oil-fashioned, and again assuming that the integer in question is 
always the very first one in parentheses:
on mouseUpput random(99) into char offset("(",yourString) + 1 of yourStringend 
mouseUp
You will get tired of running this after only a few invocations.
Craig

-Original Message-
From: Rick Harrison via use-livecode 
To: How to use LiveCode 
Cc: Rick Harrison 
Sent: Sun, Apr 26, 2020 2:26 pm
Subject: Wildcard? replaceText, offset?

I have a very long string.

In the middle-end part of the string I have “(x)” where x represents some 
integer.
it could be (4) or (10) or (5) etc.

I just want to replace the number inside the () with whatever other number I 
need to.

I have been trying to find an easy way to do this.  Ideally a wildcard 
character like ? or *
would probably do it, but after going through the dictionary and getting lost 
with
filter, matchText, …  I finally decided perhaps one of you could make a better
suggestion.  It seems like this one should be very easy, but it’s not so easy 
if you
don’t do this kind of thing all the time.

Thanks,

Rick
___
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
___
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


Re: Wildcard? replaceText, offset?

2020-04-26 Thread doc hawk via use-livecode

On Apr 26, 2020, at 11:24 AM, Rick reasoned

> In the middle-end part of the string I have “(x)” where x represents some 
> integer.
> it could be (4) or (10) or (5) etc.


If you’re certain that this is the only, or even the first, integer, a regular 
expression search and replace or [0-9]+  would  do the trick.
___
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


Wildcard? replaceText, offset?

2020-04-26 Thread Rick Harrison via use-livecode
I have a very long string.

In the middle-end part of the string I have “(x)” where x represents some 
integer.
it could be (4) or (10) or (5) etc.

I just want to replace the number inside the () with whatever other number I 
need to.

I have been trying to find an easy way to do this.  Ideally a wildcard 
character like ? or *
would probably do it, but after going through the dictionary and getting lost 
with
filter, matchText, …  I finally decided perhaps one of you could make a better
suggestion.  It seems like this one should be very easy, but it’s not so easy 
if you
don’t do this kind of thing all the time.

Thanks,

Rick
___
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