I have sample data like below
header det1 det2 det3 header det1 det2 det3 innerdescription1 innerdescription2
I want to extract only innermost match using regex
i.e val detail = "header det1 det2 det3 header det1 det2 det3 innerdescription1 innerdescription2"
Here is my code :
val ptrn="""header .*? (innerdescription2)""".r
val head = ptrn.findAllIn(detail)
But its giving the entire data again. i.e from first header to innerdescription2. I am not able to find out how to get inner match here. . Any ideas?
答案 0 :(得分:0)
You can use lookups and I believe its supported in scala.
(?<=header).*?(?=innerdescription2)
答案 1 :(得分:0)