如何使用Javascript正则表达式 - 拆分字符串而不会丢失数据并对段落进行格式化 [英] how to user Javascript regex - split string without losing data and format the paragraph

查看:120
本文介绍了如何使用Javascript正则表达式 - 拆分字符串而不会丢失数据并对段落进行格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下段落。现在我想管理下面的字符串,并且如果(1),(2)发生这种情况或者会出现特定的字符串异常,我想打破这一行。


本章的要求适用于以下内容:(1)用于医疗保健占用的新
建筑物或其部分(见
1.4.1)(2)增加到或用作医疗保健占用(见4.6.6和18.1.1.4)例外:18.1.1.1.1的要求不适用于分类为除卫生保健
以外的其他占用情况的增加(b)按照b $ b 18.1.2.1的医疗保健占用情况,并符合第12章至第17章和第20章至第42章的具体占用的要求,因为
是适当的。(3)改动,现代化,或整修
现有医疗保健占用(见4.6.7和18.1.1.4)(4)现有的
建筑物或其部分在占用改为健康
时护理占用情况(见4.6.11)例外*:具有管辖权的机构
已确定等效安全性的设施已按照第1.5节的规定提供


以下列方式: -


本章的要求适用于以下内容: / b>

(1)用作医疗保健占用的新建筑或其部分
(见1.4.1)

< (2)增加或用作医疗保健占用(见4.6.6
和18.1.1.4)

例外:要求18.1.1.1.1款不适用于根据18.1.2.1从医疗保健占用中分离出
的医疗保健以外的其他医疗保险
,并符合以下要求:
(b)根据b $ b b的第12至17章和第20至42章的具体占用情况。(b)(b)(b)(b)现代化或改造现有卫生设施
护理占用(见4.6.7和18.1.1.4)

(4)现有建筑物或其部分改变入住率
到医疗保健占用(见4.6.11)例外*:根据第1.5节提供的设施,其中具有管辖权的主管当局已确定等效安全性

b $ b

谢谢

解决方案

  var str ='(1)point 1(2)point2 exception:some exception(3)point 3'
str = str.replace(/(\(\ d + \)| exception \s * \:)/ gi,< br /> $ 1);


i have the following paragraph. Now i want to manage the string in the following and i want to break the line if (1), (2) such condition occur or a specific string Exception will occur.

The requirements of this chapter apply to the following: (1) New buildings or portions thereof used as health care occupancies (see 1.4.1) (2) Additions made to, or used as, a health care occupancy (see 4.6.6 and 18.1.1.4) Exception: The requirement of 18.1.1.1.1 shall not apply to additions classified as occupancies other than health care that are separated from the health care occupancy in accordance with 18.1.2.1 and conform to the requirements for the specific occupancy in accordance with Chapters 12 through 17 and Chapters 20 through 42, as appropriate.(3) Alterations, modernizations, or renovations of existing health care occupancies (see 4.6.7 and 18.1.1.4) (4) Existing buildings or portions thereof upon change of occupancy to a health care occupancy (see 4.6.11) Exception*: Facilities where the authority having jurisdiction has determined equivalent safety has been provided in accordance with Section 1.5.

In the following way:-

The requirements of this chapter apply to the following:

(1) New buildings or portions thereof used as health care occupancies (see 1.4.1)

(2) Additions made to, or used as, a health care occupancy (see 4.6.6 and 18.1.1.4)

Exception: The requirement of 18.1.1.1.1 shall not apply to additions classified as occupancies other than health care that are separated from the health care occupancy in accordance with 18.1.2.1 and conform to the requirements for the specific occupancy in accordance with Chapters 12 through 17 and Chapters 20 through 42, as appropriate.

(3) Alterations, modernizations, or renovations of existing health care occupancies (see 4.6.7 and 18.1.1.4)

(4) Existing buildings or portions thereof upon change of occupancy to a health care occupancy (see 4.6.11) Exception*: Facilities where the authority having jurisdiction has determined equivalent safety has been provided in accordance with Section 1.5.

Thank you

解决方案

var str = '(1)point 1 (2) point2 exception: some exception (3) point 3'
str = str.replace(/(\(\d+\)|exception\s*\:)/gi, "<br />$1");

这篇关于如何使用Javascript正则表达式 - 拆分字符串而不会丢失数据并对段落进行格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆