in reply to regex to match "---" followed by new line
Your regex does seem to do something for me... but what does your $text contain? If you're reading it from a file, are you reading the file line-by-line or are you slurping it all at once? There are several things I could point out about the regex, like how I'm not sure what (.{0,0})\K is supposed to be doing, or that the dots . will match anything, including newlines (because of /s) and dashes. But reviewing the regex doesn't make much sense without knowing what it's supposed to match against - please provide an SSCCE with several examples of what should match and what shouldn't!
use Data::Dump; dd "---\nFoo\n---\nBar\n" =~ /(.{0,0})\K(---\s*)(.{0,200})/gisx; __END__ ("", "---\n", "Foo\n---\nBar\n")
Also, note that you could set the input record separator $/ to something like "---\n" to read a file in chunks separated by that string.
|
|---|