Wildcard? replaceText, offset?
Ben Rubinstein
benr_mc at cogapp.com
Wed Apr 29 08:09:54 EDT 2020
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 <use-livecode at lists.runrev.com>
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Cc: doc hawk <dochawk at gmail.com>
> 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 youre certain that this is the only, or even the first, integer, a regular expression search and replace or [0-9]+ would do the trick.
More information about the use-livecode
mailing list