rutrum / convert-case

Converts to and from various cases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to specify `\n` as a boundary?

JosephTLyons opened this issue · comments

I'm trying to use Case::Title on some text that contains a newline (ex: The big\nblue house), but the newline isn't counted as a boundary, so I get The Big\nblue House. Is there a way to specify newlines as boundarys so I can get The Big\nBlue House? Thanks.

I tried doing something like:

let mut boundaries = Boundary::list_from("\n");
boundaries.push(Boundary::Space);

let converter = Converter::new()
    .to_case(Case::Title)
    .set_boundaries(&boundaries);

But I didn't have any luck with this.

This is not a feature at this time. You can only split a string based on a boundary condition, which is currently fixed to whatever is currently in Boundary, which doesn't include a generic "character" option. This should definitely be an option. I'd like to keep this issue open until it is fully investigated. For now, you would need to manually split the string before hand.

Manually splitting is what I ended up doing. Appreciate the response.