(clojure.string/replace myText #"(?s)START.*?END" "======") ;; "aaaaa======\neeeeee\nff\nggg\n======\nkkkkkkkk\nllll"
(?s) specifies multi-line mode, *? is the non-greedy form of *. On Thu, Jan 16, 2014 at 1:02 PM, Kuba Roth <kuba.r...@gmail.com> wrote: > Hi, > This is more of a regex specific question the clojure, but anyway... > I have the a multiline string as follow: > (def myText "aaaaaSTART > bbbb > cccc > END > eeeeee > ff > ggg > START > hhhhhhhh > ii E > jjjj > END > kkkkkkkk > llll") > > > .. and I need to replace all text between START END 'keywords' blocks. > The following regex: > (clojure.string/replace myText #"START([^END])*" "======") > > does sort of what I'm hoping to get but does not guard me against cases > when one of the "END" (in this case E) characters shows up in > the middle of the block to be cut. > So my question comes down to what am I missing here? :) > > Any suggestions are highly appreciated. > Thanks, > kuba > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.