question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multiple delimiters

See original GitHub issue

Today there is only support for a single delimiter, so some more complex patterns can’t be done.

Some examples:

  • 999.999.999-99 BR CPF (like US social security for BR people)
  • (99)99999-9999 BR phone

My proposal to fix that is add delimiters option that would take a array of delimiters, each to be used one time in the rigth order between blocks. This wouldn’t add breaking changes. Maybe some validations should be applied like not allowing both delimiter and delimiters at the same time, and delimiters.length === blocks.length - 1.

The options passed to a CPF input would be

{
  blocks: [3,3,3,2], 
  delimiters: ['.', '.', '-'], 
  numericOnly: true
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
nosircommented, Jul 31, 2016

Release published. Please see: https://github.com/nosir/cleave.js/blob/master/doc/options.md#delimiters Won’t change blocks usage, that will confuse other users.

A demo is added to homepage: http://nosir.github.io/cleave.js/

Cheers.

5reactions
gibatroniccommented, Jul 16, 2016

Another way would be to supercharge the blocks option:

{
  blocks: [3, '.', 3, '.', 3, '-', 2]
}

Which would be nice for other uses as well:

{
  blocks: [3, '.', 2, '%']
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Splitting a Java String by Multiple Delimiters - Baeldung
Learn different options for splitting an input string by multiple delimiters using regular expressions, Google Guava, and Apache Commons.
Read more >
Use String.split() with multiple delimiters - java - Stack Overflow
I think you need to include the regex OR operator: String[]tokens = pdfName.split("-|\\."); What you have will match: [DASH followed by DOT together]...
Read more >
Using multiple characters as delimiters in Excel Text to Column
Using multiple character as delimiters in Excel Text to Column where the standard text to column only allows a single character delimitor.
Read more >
HOW TO: Handle multi-character delimiters in flat-file sources ...
Click Advanced. Enter the delimiter characters under Column Delimiters. Under the Others section select Treat multiple delimiters as AND:.
Read more >
Solved: How to import a txt file with multiple delimiters?
You can define more than one character as delimiter. As long as a delimiting character can't also be a valid character in another...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found