# Using Regex on a Text Field

**URL:** <https://discourse.getcockpit.com/t/using-regex-on-a-text-field/2811>\
**Category:** Support\
**Created:** [June 18, 2023, 11:24pm UTC](https://discourse.getcockpit.com/t/using-regex-on-a-text-field/2811 "2023-06-18T23:24:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@joe](https://discourse.getcockpit.com/u/joe)\
**Post date:** [June 18, 2023, 11:24pm UTC](https://discourse.getcockpit.com/t/using-regex-on-a-text-field/2811/1 "2023-06-18T23:24:33Z")

</div>

Hello everyone.

I’m trying to add regex to a text field to limit only lowercase characters and hyphens for URL slugs.

I’ve tried setting it in the field’s Meta:

```auto
{
  pattern: '^[a-z]+(-[a-z]+)*$',
}

```

And also tried setting it in the field’s Options JSON:

```auto
{
  multiline: false,
  showCount: true,
  readonly: false,
  placeholder: null,
  minlength: null,
  maxlength: null,
  list: [],
  pattern: '^[a-z]+(-[a-z]+)*$',
}

```

However, neither seems to work. I looked through all the documentation and couldn’t find anything, or any posts on here about this, so any advice would be much appreciated.
