PDA

View Full Version : Find and replace with regualr expression type thing?


[o_O]
01-25-2003, 07:05 AM
Say that i have a <textarea> in my html page.

Then I type some txt in there.

What i need is a button that i can push which will automatically add a character to the end of each line i have just typed in that <textarea> -Well, all except the last line.

I know nothing of JS but imagine if there were some function that does similar to that of 'find and replace' + using a reg exp this would be fairly possible? i.e:

Here is what i mean:

<textarea>
line this is a line
line this is a line
line this is a line
</textarea>

> push button > txt becomes:

<textarea>
line this is a line#
line this is a line#
line this is a line
</textarea>


? If anyone knows of a script somewhere that does this or can reccomend a function i should check out I'd appreciate it.

Algorithm
01-25-2003, 10:40 AM
value = value.replace(/(.\n)(.)/g,"$1#$2");

I think that works, haven't tried it.

[o_O]
01-25-2003, 10:38 PM
I'll give it a go thanks. :)