# Hard regex

**URL:** <https://discuss.elastic.co/t/hard-regex/215714>\
**Category:** Logstash\
**Created:** [January 20, 2020, 10:38am UTC](https://discuss.elastic.co/t/hard-regex/215714 "2020-01-20T10:38:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnodl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arnodl/32/48837_2.png) [@Arnodl](https://discuss.elastic.co/u/Arnodl)\
**Post date:** [January 20, 2020, 10:38am UTC](https://discuss.elastic.co/t/hard-regex/215714/1 "2020-01-20T10:38:51Z")

</div>

hi, i need your help to write regex. It's my e.g message:  
scc\_check\_file ignored non-ASCII file /etc/sysconfig/auditd: '/etc/sysconfig/auditd: regular file, no read permission'

I want to write if, which checks in part for : (scc\_check\_file ignored non-ASCII file /etc/sysconfig/auditd) there are no such characters as: `\` , `/` , `*` , `?` , `"` , `<` , `>` , `|` , `space` (the character, not the word), `,` , `#`

---

<div class="post-metadata">

**Author:** ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)\
**Post date:** [January 20, 2020, 11:03am UTC](https://discuss.elastic.co/t/hard-regex/215714/2 "2020-01-20T11:03:12Z")

</div>

I dont understand what you're trying to do,

can you explain with details ?

also check for grok debugger and [https://regex101.com/](https://regex101.com/)

---

<div class="post-metadata">

**Author:** ![Arnodl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arnodl/32/48837_2.png) [@Arnodl](https://discuss.elastic.co/u/Arnodl)\
**Post date:** [January 20, 2020, 12:08pm UTC](https://discuss.elastic.co/t/hard-regex/215714/3 "2020-01-20T12:08:42Z")

</div>

value= "scc\_check\_file ignored non-ASCII file /etc/sysconfig/auditd: '/etc/sysconfig/auditd: regular file, no read permission'"

if [value] (to the mark 🙂 =~ /contains `\` , `/` , `*` , `?` , `"` , `<` , `>` , `|` , `space` (the character, not the word), `,` , `#`/ {  
drop {}  
}

but value up to the character :

---

<div class="post-metadata">

**Author:** ![Fabio-sama](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@Fabio-sama](https://discuss.elastic.co/u/Fabio-sama)\
**Post date:** [January 20, 2020, 1:42pm UTC](https://discuss.elastic.co/t/hard-regex/215714/4 "2020-01-20T13:42:16Z")

</div>

What about extracting the interesting part first, like:

```
  grok {
    match => { "message" => "%{DATA:partial_value}:" }
  }

  if [partial_value] =~ /[\\\/\*\?\"\<\>\|\s\,\#]/ {
    drop{}
  }

```

Obviously you can replace `message` with value if you've already extracted the `value` field.

---

<div class="post-metadata">

**Author:** ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)\
**Post date:** [January 20, 2020, 2:01pm UTC](https://discuss.elastic.co/t/hard-regex/215714/5 "2020-01-20T14:01:46Z")

</div>

Sounds good to me.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 17, 2020, 2:01pm UTC](https://discuss.elastic.co/t/hard-regex/215714/6 "2020-02-17T14:01:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
