How to remove `<` and `>` characters
See original GitHub issueThanks for maintaining slugify.
I want to strip <
and >
characters from strings, but for some reason they always convert to less
and greater
respectively. Is there a way to do this?
Here’s my input, expected result, and actual result:
slugify('Hello <world>', {
replacement: '',
remove: /[=_'\-+,<>.()[\]]/g,
lower: true,
strict: true
})
// expected: `helloworld`
// actual: `hellolessworldgreater`
Here is my workaround:
slugify('Hello <world>'.replace(/[<>]/g, ''), {
replacement: '',
remove: /[=_'\-+,<>.()[\]]/g,
lower: true,
strict: true
})
// output: `helloworld`
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How To Remove Characters from a String in Python
Remove Newline Characters From a String Using the replace() Method ... Declare a string variable with some newline characters: s = 'ab\ncd\nef'.
Read more >5 Different Ways to Remove Specific Characters From a String ...
1. Remove Specific Characters From the String. Using 'str. · 2. Remove All Characters Except Alphabets From a String. Using 'isalpha()' · 3....
Read more >5 Ways to Remove a Character from String in Python
1. Removing a Character from String using the Naive method · 2. Removal of Character from a String using replace() Method · 3....
Read more >How to remove characters/text from string in Excel - Ablebits
To remove a particular character(s) from multiple cells at once, select Remove custom characters. As an example, we are deleting all occurrences ...
Read more >Remove characters from the first string which are present in ...
Remove characters from the first string which are present in the second string ; Input: string1 = “occurrence” string2 = “car” ; Output:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@theetrain In that case, you might want to use
slug
instead ofslugify
. Assuming you want only Latin alphabet characters, by defaultslug
will only produce those.slugify
will preserve many special characters. Given the input'We Got Symbols Like ~!@*()_+'
,slugify
will output'We-Got-Symbols-Like-~!@*()_+'
by default, whileslug
will output'we-got-symbols-like'
by default.I also probably wouldn’t use two slug rules. Unless there’s an important reason, I’d suggest using
slug()
to create the user handle, and then usingString.prototype.replaceAll()
create the email handle.Output:
(Closing because I think you have your answer, but if not, feel free to re-open and/or comment.)