Hello,
I don't understand how to apply regexes on «multilines» strings.
I have discovered this problem when loading a file into a buffer. But the same apply with a multilines buffer.
See the sample under, this sample works when buffer has only one line.
A problem with the line break, but why ?
import re
var buffer="""doesn't work on multilines
this is my name:"John Dœuf""""
var extract:array[1,string]
discard match(buffer, re""".*name:"([^"]+).*""", extract)
echo extract
Thank you.
Ok i have found the answer in another forum post.
The regex computes only one line and stops at the line break.
So:
# split is in strutils
for line in buffer.split("\n"):
# regex comes here
And voila.
I've seen «streams» were also mentionned for this sort of case, but didn't search more in this direction.
It's specified when building the pattern.
re(""".*name:"([^"]+).*""", {reDotall, reStudy})