From: Sean Kinsey on
On Apr 13, 11:03 pm, Scott Sauyet <scott.sau...(a)gmail.com> wrote:
> Sean Kinsey wrote:
> > A filename with '#' or '?' in it? Are you talking about filenames
> > (used on a filesystem) or a Uniform Resource Locator (URL)?
>
> This is a legal file name in Windows XP:
>
>     `~!@#$%^&()-_=+[]{};',.txt
>
> The only restrictions I know of are against '\', '/', ':', '*', '?',
> '<', '>', and '|'.
>
>   -- Scott

It was primarily the '?' I was wondering about as it is not allowed on
Windows or on POSIX compliant systems (http://en.wikipedia.org/wiki/
Filename#Comparison_of_file_name_limitations)

Anyhow, the above regexp does the trick.
From: Sean Kinsey on
On Apr 13, 10:43 pm, "123Jim" <jnkjnjn...(a)uhnuhnunuhnuy.invalid>
wrote:
> "Sean Kinsey" <okin...(a)gmail.com> wrote in message
>
> news:76c3cced-bbbd-421a-a859-eb41c984ca12(a)z3g2000yqz.googlegroups.com...
>
>
>
>
>
> >>On Apr 13, 7:39 pm, "123Jim" <jnkjnjn...(a)uhnuhnunuhnuy.invalid> wrote:
> >> "123Jim" <jnkjnjn...(a)uhnuhnunuhnuy.invalid> wrote in message
>
> >>news:hpsm45$csl$1(a)news.eternal-september.org...
>
> >> > Hi all,
> >> > I've produced a string concatenator for a specific purpose, but it has
> >> > a
> >> > bug.
> >> >http://myweb.tiscali.co.uk/ladycroft/Rewrite_line_in_text_file_based_....
>
> >> > It's functional in firefox and chrome but in IE an extra newline (wrap)
> >> > appears in the output causing a problem. ...
>
> >> > any ideas on how to catch and kill this bug?
>
> >> > cheers.
>
> >> Turns out javascript in IE inserts a linefeed character where Firefox and
> >> Chrome do not.
> >> I have modified my javascript to take this into account and now it works
> >> as
> >> intended in IE.
>
> >> I didn't choose to use the regex method as I could not figure out how to
> >> create a regex to match every character which might, but probably won't,
> >> appear in the 'files' list.
>
> >> Here's how I killed the bug:
>
> >> var newtext = "";
> >> for(i=0;i<=numberoflines;i++){
> >> if(textarray2[i].length > 1){
> >> //if no linefeed in textarray2[i] then
> >> if(textarray2[i].lastIndexOf("\r")==-1){
> >> newtext = newtext.concat(
> >> newtext1, textarray2[i], newtext3, textarray4[i], newtext5,
> >> "\n");
> >> }else{ //for IE - delete the linefeed character
> >> //delete \r linfeed character
> >> textarray2[i] = textarray2[i].replace("\r","");
> >> newtext = newtext.concat(
> >> newtext1, textarray2[i], newtext3, textarray4[i], newtext5,
> >> "\n");
> >> }
> >> }}
>
> >> document.myform.outputtext.value = ""; //clear the text area
> >> document.myform.outputtext.value += newtext;
> >So because you couldn't create a proper regex you have opted on a
> >subpar and overly complex solution?
> >I doubt it should take anyone with a decent grip on regex more than a
> >couple of minutes to create one that works.
> >\w matches all 'word' caracters (a-z, A-Z, 0-9, _), - matches '-', \/
> >matches '/' \\ matches '\' and \. matches '.'
> >and all together: /^([-\w\/\\\.]+)(\.\w+)$/mg where the first group
> >matches the above, and the second dot followed by 'characters' (the
> >file extension).
> >I have not tested the above, but it should be fairly close.
>
> Thanks for the reply ....I tested your regex , but ,,. what if the filenames
> contains spaces, apostrophes, ~ # | ?.... What about the myriad other
> characters that may appear in a filename .. I don't intend for my code to
> break on some erroneous text list of possible 'filenames'. Also I don't
> intend the code should warn that some filenames contain illegal characters
> (in whatever platform) . the platforms vary in illegal characters I believe.
>
> I could also modify the page to process non file names .. so there might be
> very little restrictions on the characters that should be matched by the
> regex.
>
> I'm sure there must be a regex way , but I was also interested to find out
> why my code was presenting a bug in IE.
>
> cheers.

Your bug was probably due to the difference between \r which I believe
most browsers use in textareas, and \r\n which I belive IE uses.
From: Andrew Poulos on
On 14/04/2010 7:03 AM, Scott Sauyet wrote:
> Sean Kinsey wrote:
>> A filename with '#' or '?' in it? Are you talking about filenames
>> (used on a filesystem) or a Uniform Resource Locator (URL)?
>
> This is a legal file name in Windows XP:
>
> `~!@#$%^&()-_=+[]{};',.txt
>
> The only restrictions I know of are against '\', '/', ':', '*', '?',
> '<','>', and '|'.

Try naming a text file con.txt

Andrew Poulos
From: Scott Sauyet on
Andrew Poulos wrote:
> On 14/04/2010 7:03 AM, Scott Sauyet wrote:
>> Sean Kinsey wrote:
>>> A filename with '#' or '?' in it? Are you talking about filenames
>>> (used on a filesystem) or a Uniform Resource Locator (URL)?
>
>> This is a legal file name in Windows XP:
>
>>      `~!@#$%^&()-_=+[]{};',.txt
>
>> The only restrictions I know of are against '\', '/', ':', '*', '?',
>> '<','>', and '|'.
>
> Try naming a text file con.txt

Or aux.gif, or lpt1.pdf, or com3.html, or anything else using one of
the DOS reserved words.

True, and there are probably other obscure restrictions as well, but
the set of allowed characters is larger than might be expected.

-- Scott
From: Thomas 'PointedEars' Lahn on
Scott Sauyet wrote:

> Andrew Poulos wrote:
>> On 14/04/2010 7:03 AM, Scott Sauyet wrote:
>>> Sean Kinsey wrote:
>>>> A filename with '#' or '?' in it? Are you talking about filenames
>>>> (used on a filesystem) or a Uniform Resource Locator (URL)?
>>> This is a legal file name in Windows XP:
>>
>>> `~!@#$%^&()-_=+[]{};',.txt
>>
>>> The only restrictions I know of are against '\', '/', ':', '*', '?',
>>> '<','>', and '|'.
>>
>> Try naming a text file con.txt
>
> Or aux.gif, or lpt1.pdf, or com3.html, or anything else using one of
> the DOS reserved words.
^^^^^^^^^^^^^^^^^^
> True, and there are probably other obscure restrictions as well, but
> the set of allowed characters is larger than might be expected.

Pardon?


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann