# Implement a regex pattern

**URL:** <https://dmap-community.ductus.global/t/implement-a-regex-pattern/1890>\
**Category:** YANG\
**Created:** [April 22, 2018, 6:12pm UTC](https://dmap-community.ductus.global/t/implement-a-regex-pattern/1890 "2018-04-22T18:12:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shwseth](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@shwseth](https://dmap-community.ductus.global/u/shwseth)\
**Post date:** [April 22, 2018, 6:12pm UTC](https://dmap-community.ductus.global/t/implement-a-regex-pattern/1890/1 "2018-04-22T18:12:27Z")

</div>

I need to implement a regex pattern of [a-zA-Z0-9/.\_-]_[^\]_ in my yang model.  
When I try:

typedef test {  
type string {  
pattern ‘[a-zA-Z0-9/.\_-]_[^\]_’;  
}  
}

When I try this out, my cli accepts all values and doesnt apply the pattern. What do I need to do to apply this pattern in my yang model

---

<div class="post-metadata">

**Author:** ![deepakg](https://avatars.discourse-cdn.com/v4/letter/d/7ab992/32.png) [@deepakg](https://dmap-community.ductus.global/u/deepakg)\
**Post date:** [April 24, 2018, 6:07pm UTC](https://dmap-community.ductus.global/t/implement-a-regex-pattern/1890/2 "2018-04-24T18:07:27Z")

</div>

Try to commit and see if validation happens at commit time.

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [April 24, 2018, 8:33pm UTC](https://dmap-community.ductus.global/t/implement-a-regex-pattern/1890/3 "2018-04-24T20:33:01Z")

</div>

[https://yangcatalog.org/yangre/](https://yangcatalog.org/yangre/)  
Perhaps you intended to put a `\\` at the end?
