Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ltrim and rtrim #265

Open
MaccerC opened this issue May 13, 2018 · 1 comment
Open

ltrim and rtrim #265

MaccerC opened this issue May 13, 2018 · 1 comment

Comments

@MaccerC
Copy link

MaccerC commented May 13, 2018

Is it possible to trim a number of characters and not only a certain part of a string?

@RSchneyer
Copy link

I don't know if you still care, but I managed to trim a number of characters with the truncate and reverse filters.

$scope.message = 'Hello World'
<p>{{message| reverse | truncate: message.length - 7 | reverse}}</p>

results in "orld", which is the same as removing 7 characters from the left. If you want to remove characters from the right, you can just use truncate.

<p>{{message | truncate: message.length - 7}}</p>

results in "Hell"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants