# RegEx challenge (or just seems that way)

**URL:** <https://community.glideapps.com/t/regex-challenge-or-just-seems-that-way/36138>\
**Category:** Ask for Help\
**Created:** [December 20, 2021, 1:48pm UTC](https://community.glideapps.com/t/regex-challenge-or-just-seems-that-way/36138 "2021-12-20T13:48:11Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [December 20, 2021, 2:46pm UTC](https://community.glideapps.com/t/regex-challenge-or-just-seems-that-way/36138/3 "2021-12-20T14:46:19Z")

</div>

> [@Test\_Test](#):
>
> but I assume you’ll agree the default should be limited to just digits.

Nope. In my world (and in my contact list), any phone number that doesn’t start with `+` is an invalid number 😛

Validating phone numbers with regex is a bit of a slippery slope. Every time you think you’ve nailed it, you’ll find another edge case that breaks it. And before you know it you’ll have something that looks like this:

```auto
/^
 \+ [[:space:]]* [0-9] [0-9.[:space:]-]*
 ( \( [0-9.[:space:]-]* [0-9] [0-9.[:space:]-]* \) )?
 ( [0-9.[:space:]-]* [0-9] [0-9.[:space:]-]* )?
 ( [[:space:]]+ 
   ext . 
      [0-9.[:space:]-]* [0-9] [0-9.[:space:]-]* 
 )?
$/xi

```

If you really want to do it, then you’re probably better off using an existing [library](https://www.skypack.dev/search?q=phone&p=1).

> [@How to import code packages in the JavaScript column](https://community.glideapps.com/t/how-to-import-code-packages-in-the-javascript-column/34466):
>
> The [JavaScript column](https://www.glideapps.com/plugins/hell-yes-code) already includes [lodash](https://lodash.com/), which provides a value named \_ with many useful utility functions. lodash is the most popular JavaScript library in the world, so we included it by default even if you do not use it. @Jeff_Hager recently [requested](https://github.com/glideapps/glide-code-columns/issues/82) mathjs support in the JavaScript column. mathjs is another top JavaScript library, but including it by default means that every app that uses the JavaScript column would load this library as well, even though very few people need it. Tod…

---

_[View the full topic](https://community.glideapps.com/t/regex-challenge-or-just-seems-that-way/36138)._
