Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nl2br javascript

function nl2br (str, is_xhtml) {
    if (typeof str === 'undefined' || str === null) {
        return '';
    }
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
    return (str + '').replace(/([^>
]?)(
|

|
|
)/g, '$1' + breakTag + '$2');
}
Comment

nl2br javascript

function nl2br (str, is_xhtml) {
  // http://kevin.vanzonneveld.net
  // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // +   improved by: Philip Peterson
  // +   improved by: Onno Marsman
  // +   improved by: Atli Þór
  // +   bugfixed by: Onno Marsman
  // +      input by: Brett Zamir (http://brett-zamir.me)
  // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
  // +   improved by: Brett Zamir (http://brett-zamir.me)
  // +   improved by: Maximusya
  // *     example 1: nl2br('Kevin
van
Zonneveld');
  // *     returns 1: 'Kevin<br />
van<br />
Zonneveld'
  // *     example 2: nl2br("
One
Two

Three
", false);
  // *     returns 2: '<br>
One<br>
Two<br>
<br>
Three<br>
'
  // *     example 3: nl2br("
One
Two

Three
", true);
  // *     returns 3: '<br />
One<br />
Two<br />
<br />
Three<br />
'
  var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br ' + '/>' : '<br>'; // Adjust comment to avoid issue on phpjs.org display

  return (str + '').replace(/([^>
]?)(
|

|
|
)/g, '$1' + breakTag + '$2');
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native import svg image 
Javascript :: delete element 
Javascript :: react addeventlistener useeffect 
Javascript :: how to append values to dropdown using jquery 
Javascript :: get highest value in array of object javascript 
Javascript :: convert node.js to ES6 
Javascript :: loop through object in array javascript 
Javascript :: add property to object conditionally 
Javascript :: check if new user in firebase react 
Javascript :: jquery today date 
Javascript :: string contains javascript 
Javascript :: vuex use state in action 
Javascript :: svg to string javascript 
Javascript :: smooth link to anchor js 
Javascript :: moment format date 
Javascript :: nodejs aws s3 stream upload 
Javascript :: Creating a Proxy Object 
Javascript :: heroku scripts 
Javascript :: addEventListener call only once 
Javascript :: how to link a photo in expo react native 
Javascript :: javascript get query parameter 
Javascript :: swal change confirm button class 
Javascript :: javascript element in array 
Javascript :: react yup password with number string and uppercase 
Javascript :: laravel data return in json 
Javascript :: arabic regex javascript 
Javascript :: check if the document is ready js 
Javascript :: how to append value to input field using jquery 
Javascript :: mongodb connection string node example localhost 
Javascript :: quine 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =