# Regex for 2 conditions

**URL:** <https://forum.getodk.org/t/regex-for-2-conditions/24859>\
**Category:** Support\
**Tags:** kobo-toolbox\
**Created:** [February 13, 2020, 9:41am UTC](https://forum.getodk.org/t/regex-for-2-conditions/24859 "2020-02-13T09:41:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nziadat](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/nziadat/32/9748_2.png) [@nziadat](https://forum.getodk.org/u/nziadat)\
**Post date:** [February 13, 2020, 9:41am UTC](https://forum.getodk.org/t/regex-for-2-conditions/24859/1 "2020-02-13T09:41:29Z")

</div>

Hello! I am using kobo forms for a field survey.  
I wrote a regex for one number string to match and now need to add another for 2 possible answers

It should be 000-00C00000 or 000-00-0000  
regex(.,'^[0-9]{3}-[0-9]{2}[C-][0-9]{5}$') | (,.'^[0-9]{3}-[0-9]{2}-[0-9]{4}$')

The field enumerator should be able to input only either of these number formats.

I have written the expression many ways to test but I am unable to apply it. Please help. Thank you in advance.

---

<div class="post-metadata">

**Author:** ![ARIF\_AZAD\_KHAN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/arif_azad_khan/32/2921_2.png) [@ARIF\_AZAD\_KHAN](https://forum.getodk.org/u/ARIF_AZAD_KHAN)\
**Post date:** [February 13, 2020, 10:28am UTC](https://forum.getodk.org/t/regex-for-2-conditions/24859/2 "2020-02-13T10:28:20Z")

</div>

It should work on mobile end ![image](https://getodk.b-cdn.net/uploads/default/original/2X/4/42ea184b6fd8181a54719007fbdb0c06f730674d.png)

---

<div class="post-metadata">

**Author:** ![nziadat](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/nziadat/32/9748_2.png) [@nziadat](https://forum.getodk.org/u/nziadat)\
**Post date:** [February 13, 2020, 11:03am UTC](https://forum.getodk.org/t/regex-for-2-conditions/24859/3 "2020-02-13T11:03:55Z")

</div>

> [@ARIF\_AZAD\_KHAN](#):
>
> (., '^([0-9]{3}++[0-9]{2}+[C]+[0-9]{5})$') or regex(., '^([0-9]{3}++[0-9]{2}++[0-9]{3})$')

Thank you! I have tried this but it does not work. I need for one or the other option to be valid for entry and no other version.

---

<div class="post-metadata">

**Author:** ![nziadat](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/nziadat/32/9748_2.png) [@nziadat](https://forum.getodk.org/u/nziadat)\
**Post date:** [February 13, 2020, 12:15pm UTC](https://forum.getodk.org/t/regex-for-2-conditions/24859/5 "2020-02-13T12:15:16Z")

</div>

Thanks I was not able to use this regex either.
