× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 8/15/2016 4:15 PM, Booth Martin wrote:
Methinks there is a better way than what I am doing.

Can you share what you are doing?
You can use code.midrange.com and paste the link here.

I have a string like "home/One/Two/sample.txt" and want to separate it
as two strings: "home/One/Two/" and "sample.txt". I will be doing this
in an .sqlrpgle program.

Suggestions on approach to this?

I'd love to launch into a sermon on the vagaries of different file
systems, but I think I'll wait for more info. For the problem as
stated, I'd start at the end and process toward the beginning.

If performance is the question you're asking, when I'm thinking about
performance, my thoughts tend in this direction:
1) Does the code do what I want?
2) Is the performance good enough?
3) Measure performance. Record conditions and results.
4) Optimise one thing based on measurements, and re-measure.
5) After enough iterations, use table of conditions and results to
determine 'best' algorithm.

The test jig should handle as many edge cases as you can imagine, and
then ask a 4 year-old for a few more. Zero length, greater than
'maximum', no delimiters in a 'full' string, no extension in a 'full'
string. A string with multiple dots (/dir.one/dir.two/file.txt). A
string with a really long extension
(/file.some_idiot_renamed_this_file_in_order_to_keep_windows_from_finding_it_cfg)
and a file with a really short one (file.1) Strings with various
punctuation marks and most importantly, strings with non-ASCII
characters (/Zoë/documents/résumé.docx). Popular character sets include
Latin, Korean, and Chinese. For extra credit, handle Arabic and Hebrew
and other right to left languages.

That's probably better than what most people do.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.