Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function getNumbersWithFloat(value){
  2. const arrayOfIndex = value.split(' ');
  3. const lenValue = arrayOfIndex.length;
  4. const regExp = /^([0-9]+(.|,)+[0-9])|[0-9]$/;
  5. let arrayResult = [];
  6. for(var j=0; j<lenValue; j++){
  7. const match = regExp.exec(arrayOfIndex[j]);
  8. if(match != null){
  9. arrayResult.push(arrayOfIndex[j]);
  10. console.log(arrayResult);
  11. }
  12. }
  13. }
  14. getNumbersWithFloat('string and num 123 and 56K7 3,4 76 9,7, 9.0float');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement