Skip to main content
Commonmark migration
Source Link

#JavaScript (ES), 165 161 156 154 153 bytes#

JavaScript (ES), 165 161 156 154 153 bytes

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

##Try It##

Try It

f=

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

#JavaScript (ES), 165 161 156 154 153 bytes#

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

##Try It##

f=

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

JavaScript (ES), 165 161 156 154 153 bytes

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

Try It

f=

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

added 9 characters in body
Source Link
Shaggy
  • 45k
  • 4
  • 39
  • 95

#JavaScript (ES), 165 161 156 154154 153 bytes#

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>(a=[],[n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),aa=[])|a.mapfilter(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),yx=>x>47&x<58|x>64&x<91|x>96&x<123).length

##Try It##

f=

n=>(a=[],[n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),aa=[])|a.mapfilter(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),yx=>x>47&x<58|x>64&x<91|x>96&x<123).length

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

#JavaScript (ES), 165 161 156 154 bytes#

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>(a=[],[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),y)

##Try It##

f=

n=>(a=[],[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),y)

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

#JavaScript (ES), 165 161 156 154 153 bytes#

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

##Try It##

f=

n=>[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}"),a=[])|a.filter(x=>x>47&x<58|x>64&x<91|x>96&x<123).length

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

deleted 1 character in body
Source Link
Shaggy
  • 45k
  • 4
  • 39
  • 95

#JavaScript (ES), 165 161 156156 154 bytes#

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>(a=[],r=[[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),y)

##Try It##

f=

n=>(a=[],r=[[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123),y=0),y)

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

#JavaScript (ES), 165 161 156 bytes#

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>(a=[],r=[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),y)

##Try It##

f=

n=>(a=[],r=[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123),y=0),y)

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

#JavaScript (ES), 165 161 156 154 bytes#

Yeah, RegEx definitely wasn't the right tool for the job here!

n=>(a=[],[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),y)

##Try It##

f=

n=>(a=[],[/\d{2}/g,/\d{3}/g].map(e=>eval("while(x=e.exec(n)){a.push(m=x[0]);e.lastIndex-=m.length-1}")),a.map(x=>y+=x>47&x<58|x>64&x<91|x>96&x<123,y=0),y)

console.log(f(5698))//3
console.log(f(564693))//2
console.log(f(530923864209124521))//3
console.log(f(1111111))//5
console.log(f(5115643141276343))//4
console.log(f(56789))//4
console.log(f(94))//0
console.log(f(1))//0

deleted 3 characters in body
Source Link
Shaggy
  • 45k
  • 4
  • 39
  • 95
Loading
Source Link
Shaggy
  • 45k
  • 4
  • 39
  • 95
Loading