Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Chrtran() applied selectively
Message
From
07/06/2016 13:24:52
 
 
To
07/06/2016 02:58:33
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01636985
Message ID:
01637079
Views:
46
>>I am searching for the most expedient way to change a character in a specific area of a string.
>>
>>mstr='1st-title: ANAME-HER : 3520931 place[21-22]'
>>in this string the hyphen between 21 and 22 should be a dot.
>>if I applied chrtran() I would end up changing all the hyphens which I do not want to do.
>>
>>right now all I've been able to accomplish is to locate the error in a portion of the string, but putting it back together is starting to get a bit unwieldy.
>>Is there a simpler more direct route of directing the chrtran() to the area beyond '['
>>
>>thanks
>>k
>
>Hi Karen:
>
>Another solution here :D
>
>Considering that there are always three "parts" separated by ":" symbol, this will do it in pure VFP:
>
>
>mstr='1st-title: ANAME-HER : 3520931 place[21-22]'
>? GETWORDNUM(mstr, 1, ':') + ':' + GETWORDNUM(mstr, 2, ':') + ':' + CHRTRAN(GETWORDNUM(mstr, 3, ':'), '-', '.')
>
thanks Fernando - that was my first approach but I did not know how to set it up. I was using at() for string location, cutting up the string then reassembling it - it got very messy. this will come in very handy. many thanks. K
Previous
Reply
Map
View

Click here to load this message in the networking platform