From: 123Jim on 13 Apr 2010 13:39 "123Jim" <jnkjnjnini(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_on_contents.html > > 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;
From: Sean Kinsey on 13 Apr 2010 15:01 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.
From: 123Jim on 13 Apr 2010 16:43 "Sean Kinsey" <okinsey(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.
From: Sean Kinsey on 13 Apr 2010 16:54 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. A filename with '#' or '?' in it? Are you talking about filenames (used on a filesystem) or a Uniform Resource Locator (URL)? Its no problem creating a simple regexp either way, for instance /^(. +?)(\.\w+)$/mg This will match all 'filenames' and give you the two groups you need.
From: Scott Sauyet on 13 Apr 2010 17:03 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
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: FAQ Topic - Why are my rollovers so slow? (2010-04-11) Next: Help with "location.replace" |