Talk:File extension is in extensions list

From Rosetta Code
Revision as of 20:57, 12 August 2014 by rosettacode>Gerard Schildberger (→‎Dupe?: commented about the fly-in-the-oinment.)

Dupe?

I know it's not exactly the same but is this a close duplicate of Search a list? This one has an odd requirement that it has to be a file extension, but the other one has the extra requirement of using an indexed list. I think they're close enough and Search a list has the advantage of already being implemented a lot and not restricting the data. --Mwn3d (talk) 16:56, 11 August 2014 (UTC)

Well, the file extension has to be parsed, and there is the case of the filename not having an extension (so the requirement of having to have a file extension ... isn't).   The handling of insensitive case is a minor requirement.   It's a common enough task to warrant it's own task. -- Gerard Schildberger (talk) 20:28, 11 August 2014 (UTC)
Also, just to note, some filenames that have no file extenstion:
  • somefile
  • holy smoke
  • afile.
  • /a/path/to/glory.yup/or_not
  • funny...
  • unusual.½xy
  • fly_in_the_ointment. imbedded_blank_after_the_period

-- Gerard Schildberger (talk) 20:28, 11 August 2014 (UTC)
-- Gerard Schildberger (talk) 19:07, 12 August 2014 (UTC) {added two more examples above.}

I didn't read it quite right the first time and didn't see that the entire filename is an input rather than just its extension. I think it would be better to have a task for separating the file extension from the full filename without the list search task that this one is similar to. The task here is just combining two really simple tasks into an uncommon compound task. --Mwn3d (talk) 20:50, 11 August 2014 (UTC)
That's what I thought at first, until I (gasp!) actually read my own post) ... and found that it's not that simple (separating a file extension from a filename that may have no valid extension?) --- but certainly not that complicated, but worthy of some thought.   I went for the boilerplate solution route (for REXX). -- Gerard Schildberger (talk) 21:08, 11 August 2014 (UTC)
Yeah it doesn't sound very different from the search task in my head but now that I've done it I see it has some key variations--most notably (for my Java version anyway) was the case-insensitivity. --Mwn3d (talk) 17:21, 12 August 2014 (UTC)
I found that the fly-in-the-ointment (above, which deals with imbedded/leading/trailing blanks) to be a bit of a thorn in one's side, but after some thought, it only took one extra REXX program statement to make it compliant, the comment dealing with it however, was a lot larger. -- Gerard Schildberger (talk) 20:57, 12 August 2014 (UTC)