I think this is just a consequence of regex match then split. As you ask for splitting by ; and you have one at the end of each character, the result is an empty character after the split.
the internal split function behind separate_rows is stringi::stri_split_regex that have an omit_empty argument FALSE by default.
# keeping empty
stringi::stri_split_regex("1863574; 11844758 (contact);",
pattern = "(\\(contact\\);|;)")
#> [[1]]
#> [1] "1863574" " 11844758 " ""
# dropping empty
stringi::stri_split_regex("1863574; 11844758 (contact);",
pattern = "(\\(contact\\);|;)", omit_empty = TRUE)
#> [[1]]
#> [1] "1863574" " 11844758 "
Created on 2018-10-11 by the reprex package (v0.2.1)
separate_rows uses omit_empty = FALSE the default. So to use it and not having empty rows you should
- clean before the string to split but you have several endings (
(contact); or ; to remove
- clean after with
filter as you proposed
- don't use
separate_rows and do the splitting yourself changing the default
Also, if you don't want the space before or after the split results, you could add optional space in regex \\s? or trim afterward using mutate.
Hope it helps