#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    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.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2002
    Posts
    693
    Rep Power
    26
    just use the replace function.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    68
    Rep Power
    12
    Please try:

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

    Cheers,
    Dan
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    3
    Rep Power
    0

    carriage returns in text string


    Thank you

    I have been able to resolve the problem with the expert guidance provided.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    2
    Rep Power
    0

    Thumbs down Javascript: Split on Carriage Returns


    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
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    2
    Rep Power
    0

    Wink Success !!!


    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;

    }

IMN logo majestic logo threadwatch logo seochat tools logo