0

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

4
  • 1
    I think he'd like to have the bulk of text in unformatted form. that is the problem he's trying to solve using JS. Commented Apr 9, 2013 at 9:17
  • finally somebody introduced back the problem into the question :D Commented Apr 9, 2013 at 9:34
  • @Allendar: I think your edit was quite contraproductive, as you changed the OPs input and output representation. Commented Apr 9, 2013 at 9:34
  • possible duplicate of previous question: str.split() pass muliple delimeter one regular expression and another string (with code, but without example) Commented Apr 9, 2013 at 10:14

1 Answer 1

1
var str = '(1)point 1 (2) point2 exception: some exception (3) point 3'
str = str.replace(/(\(\d+\)|exception\s*\:)/gi, "<br />$1");
Sign up to request clarification or add additional context in comments.

7 Comments

The two directly nested matching groups look really unnecessary…
Actually, you could remove them fully and use $& in the replacement :-)
Thanks. new thing learnt, str.replace(/\(\d+\)|exception\:/gi, "<br />$&1"). Please tell me it's all better now :D
No, without the 1 - see MDN's docs
oops... str.replace(/\(\d+\)|exception\:/gi, "<br />$&") didn't notice the 1 in front of all replacements... thanks a lot. 2000 visits on your profile!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.