I don't know if this would interest anyone but me, this thread got to me to thinking about a method I wrote years ago for my library class to clean text up and remove a default set of characters, but I can also pass a custom set of characters to be removed. It's called CLEANTEXT and the heart of it is the CHRTRAN command that Frank suggested.
His command noted it would leave behind invalid characters. So as a mental exercise, I created a new method called CLEANTEXT_NUMBER and it will use Frank's command to identify the invalid characters and then remove those invalid characters from the original string to leave you with only the good characters you want to leave behind without needing to know the invalid characters you want removed. In this new method, you just need to know what you want to keep. For example if you don't pass a value for the pcRequestedChars, it will assume you want just the digits to remain. But if you pass a special list of requested characters, it will return just those characters if they exist in the original string.
PARAMETERS pcStringToClean, pcRequestedChars
LOCAL leRetVal, lcValidChars, lcRemoveChars
If pcount() = 1
lcValidChars = "0123456789"
else
lcValidChars = pcRequestedChars
endif
lcRemoveChars = CHRTRAN(m.pcStringToClean, m. lcValidChars, "")
leRetVal = CHRTRAN(m.pcStringToClean, m.lcRemoveChars, "")
RETURN leRetVal
Stupid stuff I know, but a nice quick mental exercise! Thanks, Frank!
Paul H. Tarver
-----Original Message-----
From: ProfoxTech [mailto:profoxtech-***@leafe.com] On Behalf Of Frank Cazabon
Sent: Friday, May 18, 2018 8:01 AM
To: ***@leafe.com
Subject: Re: String help (was Re: [ADMIN] Testing post to ProFox)
m.x="123-456-7890"
CHRTRAN(m.x, "0123456789-", "") will leave any invalid characters behind
Frank.
Frank Cazabon
Well, other post still not making it, so I'll add the simple request
FieldValue1 = '123-456-7890'
I want to scan for records where the field contains something OTHER
than digits 0-9 and a dash. I recall it was some magic with one of
the TRANS that compared to itself and thus if the result was not
equal, it meant the field contained invalid characters outside your
desired set.
tia,
--Mike
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ***@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/04b701d3eec0$de5e7460$9b1b5d20$@tpcqpc.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.