Q:

removing a pipe sign from text with javascript

I have some text that I am rendering using underscore and it contains pipe character that I am trying to remove.
This is what I have tried
<script type="text/html" id="activityDescriptionTmpl">
    <%=  formatInput(container.CurrentActivity.ProcessActivityDescription) %>
</script>

this is what the text looks like 
This is the text with pipe character at the end|

This id a javascript function I created
formatInput = function (input) {
        var arr = [];
        var finalInput = '';
        if (input.indexOf('|') > 0) {
            arr = input.split('|');
            for (var i = 0; i < arr.length; i++) {
                if ($.trim(arr[i]).length > 0)
                    finalInput += $.trim(arr[i]) + '<br />';
            }
        }
        else {
            finalInput = input;
        }
        return finalInput;
    };

But in this case I get the errorcannot read property 'indexOf' undefined
Is there perhaps a better way of just removing this pipe character

A:

Try newInput = input.replace("|", "");
http://jsfiddle.net/robschmuecker/sGKf3/

