简体   繁体   中英

Split By 2 String Delimiters via RegEx Javascript

I am relatively new to RegEx and need help splitting up a section of text by two delimiters, and then capturing what's between them. For instance, I have a JSON object that has a "description" property, and it essentially contains this text:

This is yet another test product to test for all sorts of styling/formatting issues. 

PLACEHOLDER

PLACEHOLDER

PLACEHOLDER

******

Not so expensive
Works all day
Works throughout the night
No risk
100% Guarantee
------

This would be where ingredients would go for Test Product 4.

What I am trying to do is to capture the "bulleted" list between the six-asterisk delimiter and the 6-dash delimiter. So in the above example, I want to be able to capture these lines:

Not so expensive
Works all day
Works throughout the night
No risk
100% Guarantee

Thus, I need to split by two delimiters:

1) ******
2) ------

After searching around this and other forums, I still can't seem to get any form of .split() method and RegEx to get precisely what I want. Is anyone able to help me out here? The ultimate goal is to be able to capture that text and then append it to a <div>

No? Really?

string.split(/------|\*\*\*\*\*\*/);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM