Trim string from center, starting with spaces
I have an odd question.
Let's say I have a string like this:
/ / \ \
What I want to do is trim the string from the center to a certain length,
but primarily trimming spaces and then other characters.
For example, if I wanted to trim that string to 10 characters, it might
look like this:
/ /\ \
But then if I want to reduce it further, to 4 characters, it might look
like this:
//\\
And then finally, once I get down to no spaces left in the string, I want
to trim from the center, but remove all characters. So if I want my string
to now become only 2 characters, it might look like this:
/\
And if I have a string like this:
b a ab
And I trim it to 2 characters using this function, it would look like this:
aa
Is this possible, and if so, how?
No comments:
Post a Comment