用\ s替换\ r \n's

gsc*_*ish 0 regex jquery json

我已经成功地获得了下面的JSON,但是我有一个问题,那些讨厌的正则表达式\ r \n\r \n进入<br/>'s.我目前正在使用以下代码,但它只是逃避了一些.我正在寻找替换正则表达式的所有实例,包括:\ r \n,\ r \n\r \n.我之前使用的代码是:

$('<ul class="job-listing"><li class="job-position"><h2>'+post.m_positionName+'</h2></li><li class="job-description">'+post.m_description.replace('\r\n','<br />')+'</li></ul>').appendTo('body');
Run Code Online (Sandbox Code Playgroud)

这是JSON:

[
  {
    "m_id": 473644,
    "m_positionName": "Application Monitoring Software Engineer",
    "m_positionLocations": [
      {}
    ],
    "m_active": true,
    "m_description": "Job Responsibilities:\r\n\r\n-Create world class application monitoring tools and dashboards for our health care applications\r\n\r\n-Develop business rules to pro actively identify and re-mediate system-level issues before they occur.\r\n\r\n-Create business intelligence reports for internal and external use as a supplement to software products.\r\n\r\n\r\n\r\nJob Requirements:\r\n\r\n-BS or MS Degree in computer science or any engineering discipline.\r\n-4+ years of experience with Java (or other object-oriented programming language).\r\n-Experience in SQL, Struts, Hibernate, Spring, Eclipse, JSP, JavaScript.\r\n-Highly motivated and self-driven personality.\r\n-Excellent interpersonal and leadership skills.\r\n-A vision for the future and a desire to make a difference.\r\n-Experience with Maven, Tomcat, PostgreSql, Jasper Reports,",
    "m_postedDate": "Jun 29, 2012 9:17:19 AM",
    "m_closingDate": "Jun 29, 2013 12:00:00 AM"
  }
Run Code Online (Sandbox Code Playgroud)

Kon*_*nev 6

用这个:

post.m_description.replace(/\r\n|\n|\r/g, '<br />');
Run Code Online (Sandbox Code Playgroud)