iteye_10724
2009-06-29 19:16
浏览 436

正则表达式 关于转义符的替换

在javascrpt中,有下面的内容[code="java"] msglistValue = '{"totalProperty":24,"dataList":[{"typeSign":"site_unread","msgContent":"\"\"<\/p>

发件人:88001223<\/font><\/p>

发件时间:2009-5-26 12:32:7<\/font><\/p>","msgSubject":"send mesgddddd","sender":"88001223","status":"success","senderId":"6562","sign":"unread","msgId":"637","activityId":"0","receiver":"88001223","receiverId":"6562","label":"common","msgType":"site","source":"msg","priority":"normal","sendDate":"2009-06-26"},{"typeSign":"site_read","msgContent":"beyond 1983---1993","msgSubject":"反复反复反复反复反复发放","sender":"88001231","status":"success","senderId":"6569","sign":"read","msgId":"636","activityId":"0","receiver":"88001223","receiverId":"6562","label":"common","msgType":"site","source":"msg","priority":"normal","sendDate":"2009-06-22"}]}';[/code]
要把内容中的【\"】 替换成[\\"] ,原因是在Ext.util.decode(msglistValue );回报【无法解析字符】。
球各位达人 多多帮忙 ,着急啊

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 成富 2009-06-29 23:35
    已采纳

    这个地方,正在表达式是不起作用的,因为在字符串里面,并没有\,\"实际上就等于"。你要做的是对由FCKEditor生成的HTML内容进行转义,把<、>、和"都进行转义,变成<、>和&quot;这样的话,再变成JSON的时候就不会出问题了。

    已采纳该答案
    打赏 评论
  • zhangrunzgz 2009-06-30 09:06

    [code="java"] alert(msglistValue.replace(/\"/g,"\\""));[/code]

    楼主试试这个。

    打赏 评论
  • liukaihandsome 2009-07-03 12:58

    你这个是AJAX吧
    单独写个.JS
    把要解析的随便
    在一个***.properties文件ADD下
    再看Source

    打赏 评论

相关推荐 更多相似问题