I have a big html file, i want to parse it in kotlin or java, i'm trying
first to to match everything between <body
and </body>
using a simple regex like
<body(.|\n)+</body>
but surely i'm faced with the stackOverFlow error, here's the code in kotlin
//original html
val file= File("""/home/yazan/Documents/books.xml""")
//empty file
val file2= File("""/home/yazan/Documents/books2.xml""")
val reg="""<body(.|\n)+</body>""".toRegex()
val text= reg.find(file.readText())
text?.value?.let { file2.writeText(it) }
how can I regex large files in a memory-efficient way ?