digitalmars.D.learn - enforce with return type RegexMatch!string
- berni (11/18) Sep 11 2018 I call this function using enforce(extract_list(some_argument)).
I've got the folling function which returns a RegexMatch!string:auto extract_list(const string entry) { // check if entry is valid return matchAll(entry, some_regex); }I call this function using enforce(extract_list(some_argument)). I think, that enforce is quite useless in this version. But I'd like to add a check, if entry is valid in the extract_list-function, something like:if (!matchFirst(entry, other_regex)) return null;That doesn't work, because I cannot cast null to RegexMatch!string (I don't understand why). What works is to create a string[] from the result of matchAll (using map and array) and use that array instead of the range. Now I can return null too. Is there a way to accomplish this?
Sep 11 2018