Last active
September 22, 2019 07:09
-
-
Save gthrm/44a7ce708001c8282ce050daf4a42e6f to your computer and use it in GitHub Desktop.
RegExp + switch JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switch (digitsOnly) { | |
case digitsOnly.match(/\s+/g) ? digitsOnly : true: | |
result = digitsOnly.replace(/\s+/g, '');/* оставляем только цифры, удаляем пробелы*/ | |
break; | |
case digitsOnly.match(/\.+/g) ? digitsOnly: true: | |
result = digitsOnly.replace(/\.+/g, '');/* оставляем только цифры, удаляем точки*/ | |
break; | |
case digitsOnly.match(/^\d+/g) ? digitsOnly: true: | |
result = digitsOnly.replace(/\s+/g, '');/* оставляем только цифры, удаляем пробелы*/ | |
break; | |
default: | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment