Helpful Information
 
 
Category: Oracle Development
carriage returns in text string

I am wishing to extract the contents of a column with datatype varchar2(100) which holds concatenated address data with carriage returns so when used within the application the address elements appear on seperate lines.

I wish to replace the carriage return characters with a comma so the address elements are split into individuals fields as part of the extract

How do I
a) search for the carriage return character in the string
b) replace the carriage return character with a comma.

I believe I should be using the chr function but I am not sure how.

Can someone provide any answers or guidance please.

Thank you in anticipation.

just use the replace function.

Please try:

select replace('linee
eee',chr(13),'c') from dual

Cheers,
Dan

Thank you

I have been able to resolve the problem with the expert guidance provided.

Objective:
I want to be able to count in real time (using Javascript) to count how many combination words after each carriage return entered in the <textarea> tag occurs. i.e if data in <textarea> tag has this:



I want to see<Enter>
This is so


I expect the count to say "2".

Setup:
I have two input boxes. The first is the <textarea> where the words are entered with identifier of say "name=textareadata" .
I also have a 2nd inout box where I want the count to be displayed in real time with identifier say "name=counter" . For the <textarea> tag, I also have this "onKeyup=ShowCount()". The <form> tag has identifier say "name=formdata" .

Javascript Code Snippet:



function ShowCount()
{
var count = document.formdata.textareadata.value;
count = count.split(chr(13));

document.formdata.counter.value = count.length;
}


This does not work. I have actually tried other stuff with regexp etc ... with no luck. The real time update works though as I replaced "count.split(chr(13))" with "count.split(" ")" and is successfully shows the exact count as I enter the data. If I remove the data it decreases the counter. But I want to count combinations words count after each carriage return.

Anyone !!

Thanks :confused:

I kept trying and finally got it. Here's the code that did the job:

function ShowCount()
{
var sTextArea = document.formdata.textareadata.value,
re = /\r\n/g,
aHTMLComments = sTextArea.split(re);

document.formdata.counter.value = aHTMLComments.length;

} :D