I want to split a long scala file by the javadoc it contains, into some parts.
source split """(?s)\/\*\*(.*?)\*\/"""
works, but it will ignore all the javadoc it matchs.
How to get all parts?
For example:
/** package */
package test
/**
* Class user
*/
class class User
It will be split into 4 parts:
/** package */
and
package test
and
/**
* Class user
*/
and
case class User
How to do it?
Try these:
As dhg said, using regex to solve such a problem is not recommended. It’s slow and fragile.