Using regular expression to get the array between the two marks

#word1#--start--#word2#word3#dflsjdf#--end--#word4#word5#

Problem: using regular expression to get the array of words between the two marks (start, end) To result in a
word2, word3, dflsjdf
Words can be an arbitrary number.
October 3rd 19 at 03:53
3 answers
October 3rd 19 at 03:55
/--start--#(.*)#--end--/ and then the obtained result is split by the #symbol
And one expression? - alexanne26 commented on October 3rd 19 at 03:58
What is JAPANESE writing? the regexp itself nothing breaks - allen.Mayer commented on October 3rd 19 at 04:01
October 3rd 19 at 03:57
If only one regular expression, then it is possible that:

/--start--#(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?(?:([^#]*)#)?--end--/

Only here the random number is not obtained, up to a certain number (here, up to fifty). Well, the result is, shall we say, not entirely clean — but then it all depends on the language you use.
Okay, I agree, this is a very shitty solution, but isn't that the only way to solve the problem in just one regular expression? If you have a better idea, I would love to see it. - alexanne26 commented on October 3rd 19 at 04:00
(?:--start--#|\G)(\w+)#(?=[\w#]*--end--) - allen.Mayer commented on October 3rd 19 at 04:03
October 3rd 19 at 03:59
(/--start--#(.*)#--end--/).split("#").toArray(); — one expression
the same regular expression. - alexanne26 commented on October 3rd 19 at 04:02

Find more questions by tags Regular expressions