I want to see a class that represents a part of the existing string. Something that I can use in the following manner:
val theBigString: String = ???;
val pattern: Regex = ???;
val mySubstring = SmthLikeStringView(theBigString, /*start*/ 1000, /*end*/ 1500);
if (pattern.matches(mySubstring)) {???;} else {???;}
Of course I know about the following stuff, but it seems not to fit:
val mySubstring = theBigString.substring(/*start*/ 1000, /*end*/ 1500). The resulting object has nice interface, which I like. But AFAIK, the operation implies literally copying character, which I want to avoid, I'd like to create a "lightweight" object.val mySubstring = scala.collection.StringView(theBigString).slice(/*start*/ 1000, /*end*/ 1500). This is really aView(hopefully, lightweight enough), but it has inappropriate interface. Not only it has unexpected method names (e.g.sliceinstead ofsubstring), but it also doesn't implementCharSequence, so I can't operate on it viaRegexand other standard ways.
Is there something that (on the one hand) is lightweight, view-like and (on the other hand) can be used together with Regex?
(AFAIK, no. But then the questions are: (1) WHY??? (2) Are there any bug reports / feature requests for that?)