From: 123Jim on
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.


From: Sean Kinsey on
On Apr 11, 4:25 pm, "123Jim" <jnkjnjn...(a)uhnuhnunuhnuy.invalid> wrote:
> 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.

Does this do the trick?

var input ="My-Video.wmv\nMy-Video2.wmv\n";
var reLine = /^([-\w]+)(\.\w+)$/m;
var output = input.replace(reLine,"<li><a onclick=
\"play(this.href);return false\" href=\"$1$2\">$1</a></li>");



From: 123Jim on

"Sean Kinsey" <okinsey(a)gmail.com> wrote in message
news:3140c66c-654c-4368-8449-29e6a27dcfca(a)r18g2000yqd.googlegroups.com...
On Apr 11, 4:25 pm, "123Jim" <jnkjnjn...(a)uhnuhnunuhnuy.invalid> wrote:
>> 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.

>Does this do the trick?

> var input ="My-Video.wmv\nMy-Video2.wmv\n";
> var reLine = /^([-\w]+)(\.\w+)$/m;
> var output = input.replace(reLine,"<li><a onclick=
> \"play(this.href);return false\" href=\"$1$2\">$1</a></li>");

clever stuff! .. That regex is alien to me ;)
It does work the same in firefox and IE ... but so far I only have it
returning one line for the first list item, and the unchanged remaining list
items.

what is that $1$2 stuff? looks like perl variables..
How does it 'know' those are the names in the list?

and how can I have it process all the list items?

I guess understanding your regex would explain all ..
know of a good online resource?



From: Øyvind Sean Kinsey on
Den 11.04.2010 18:41, skrev 123Jim:
> "Sean Kinsey"<okinsey(a)gmail.com> wrote in message
> news:3140c66c-654c-4368-8449-29e6a27dcfca(a)r18g2000yqd.googlegroups.com...
> On Apr 11, 4:25 pm, "123Jim"<jnkjnjn...(a)uhnuhnunuhnuy.invalid> wrote:
>> Does this do the trick?
>
>> var input ="My-Video.wmv\nMy-Video2.wmv\n";
>> var reLine = /^([-\w]+)(\.\w+)$/m;
>> var output = input.replace(reLine,"<li><a onclick=
>> \"play(this.href);return false\" href=\"$1$2\">$1</a></li>");
>
> clever stuff! .. That regex is alien to me ;)
> It does work the same in firefox and IE ... but so far I only have it
> returning one line for the first list item, and the unchanged remaining list
> items.

Add the global flag to the regexp :/^([-\w]+)(\.\w+)$/mg
^
>
> what is that $1$2 stuff? looks like perl variables.

Thats references to the two matched groups, grouped by the parentices ()

> How does it 'know' those are the names in the list?

Not sure what you mean

>
> and how can I have it process all the list items?

See above

>
> I guess understanding your regex would explain all ..
> know of a good online resource?

A good tip is to actually try to find the information your self before
asking others about it. Hint: google it.
From: 123Jim on

"�yvind Sean Kinsey" <oyvind(a)kinsey.no> wrote in message
news:4bc1ffca$0$3271$afc38c87(a)read01.usenet4all.se...
> Den 11.04.2010 18:41, skrev 123Jim:
>> "Sean Kinsey"<okinsey(a)gmail.com> wrote in message
>> news:3140c66c-654c-4368-8449-29e6a27dcfca(a)r18g2000yqd.googlegroups.com...
>> On Apr 11, 4:25 pm, "123Jim"<jnkjnjn...(a)uhnuhnunuhnuy.invalid> wrote:
>>> Does this do the trick?
>>
>>> var input ="My-Video.wmv\nMy-Video2.wmv\n";
>>> var reLine = /^([-\w]+)(\.\w+)$/m;
>>> var output = input.replace(reLine,"<li><a onclick=
>>> \"play(this.href);return false\" href=\"$1$2\">$1</a></li>");
>>
>> clever stuff! .. That regex is alien to me ;)
>> It does work the same in firefox and IE ... but so far I only have it
>> returning one line for the first list item, and the unchanged remaining
>> list
>> items.
>
> Add the global flag to the regexp :/^([-\w]+)(\.\w+)$/mg
> ^
>>
>> what is that $1$2 stuff? looks like perl variables.
>
> Thats references to the two matched groups, grouped by the parentices ()
>
>> How does it 'know' those are the names in the list?
>
> Not sure what you mean
>
>>
>> and how can I have it process all the list items?
>
> See above
>
>>
>> I guess understanding your regex would explain all ..
>> know of a good online resource?
>
> A good tip is to actually try to find the information your self before
> asking others about it. Hint: google it.


Thanks, got it working now ..
Of course my first recourse was to web search for stuff on regex, but
everyone in the world has a favourite resource on regex right?

One of the things I have learned here is that regex can simplify/save many
lines of code in specific cases. .. I just gotta learn to use it.
Thanks again.