开发者

regex split problem

开发者 https://www.devze.com 2022-12-27 15:34 出处:网络
I have javascript string variable with var sttr=\"We prefer questions that can be answered --------------------- not just discussed ---------------------

I have javascript string variable with

var sttr="We prefer questions that can be answered --------------------- not just discussed ---------------------
Provide details ---------------------------- Write clearly and simply --------------------------answer all the question"

please suggest how to split the string into array of sentences on the basis of dashes(-----) using regex

result should be

array[0]=We prefer quest开发者_如何学Cions that can be answered
array[1]=not just discussed
array[2]=Provide details
array[3]=rite clearly and simply
array[4]=answer all the question

Note: dash(-----) range after each sentence is between 10 to 50


You want to split on /-{10,50}/g.

See also

  • regular-expression.info/Limiting repetition
  • Javascript regular expressions methods and usage


sttr.split(/-+/g);

Test it with regular expression tester

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号