# Extend regular expressions for non-strings

**URL:** https://es.discourse.group/t/extend-regular-expressions-for-non-strings/516
**Category:** 💡 Ideas
**Created:** [October 26, 2020, 10:27am UTC](https://es.discourse.group/t/extend-regular-expressions-for-non-strings/516 "2020-10-26T10:27:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jaroslav.tavgen](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jaroslav.tavgen/32/2732_2.png) [@jaroslav.tavgen](https://es.discourse.group/u/jaroslav.tavgen)
#### Post date: [October 26, 2020, 10:27am UTC](https://es.discourse.group/t/extend-regular-expressions-for-non-strings/516/1 "2020-10-26T10:27:25Z")

</div>

Very simple:

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].match(/[02468]/g) would give the result [0, 2, 4, 6, 8]  
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].match(/[02468]/) would give the result [0]  
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].match(/[345]+/g) would give the result [345]

---

<div class="post-metadata">

### Author: ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)
#### Post date: [October 26, 2020, 7:51pm UTC](https://es.discourse.group/t/extend-regular-expressions-for-non-strings/516/2 "2020-10-26T19:51:56Z")

</div>

Wouldn't this only be useful for arrays whose items were entirely toString-able?

---

<div class="post-metadata">

### Author: ![jaroslav.tavgen](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jaroslav.tavgen/32/2732_2.png) [@jaroslav.tavgen](https://es.discourse.group/u/jaroslav.tavgen)
#### Post date: [October 27, 2020, 7:05am UTC](https://es.discourse.group/t/extend-regular-expressions-for-non-strings/516/3 "2020-10-27T07:05:42Z")

</div>

Maybe. But as I understand, operations with strings are costly in the means of performance, so FAST means of working with arrays while using the syntax of regular expressions would be nice!

Also! Not only arrays! Why not this?

123456.match(/[024]/g) returns 24  
123456.match(/[024]/) returns 2
