# Writing my own filter plugin. What is the best way to implement the regex matching?

**URL:** <https://discuss.elastic.co/t/writing-my-own-filter-plugin-what-is-the-best-way-to-implement-the-regex-matching/178328>\
**Category:** Logstash\
**Created:** [April 24, 2019, 9:02pm UTC](https://discuss.elastic.co/t/writing-my-own-filter-plugin-what-is-the-best-way-to-implement-the-regex-matching/178328 "2019-04-24T21:02:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcaballero](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jcaballero](https://discuss.elastic.co/u/jcaballero)\
**Post date:** [April 24, 2019, 9:02pm UTC](https://discuss.elastic.co/t/writing-my-own-filter-plugin-what-is-the-best-way-to-implement-the-regex-matching/178328/1 "2019-04-24T21:02:30Z")

</div>

I am learning how to write my own custom filter plugin. Just started. I got the basics.

For my case, the input lines (or events) are like this

```
key1 = value1
key2 = value2
...
======
key6 = value6
key7 = value7
...
======
...

```

where values can be anything, a number, a single word, a long string, ...

I would like to get, and manipulate, the values for a list of provided keys.  
My question is, what is the best way here for me to do the matching?

1. should I just investigate how to do regular expressions in ruby?
2. copy & paste from an existing plugin that does the same, or similar? If yes, which one would you recommend?
3. can a plugin import classes and methods from other plugins? If yes, would be the best way to have my plugin to call, somehow, logstash-filter-grok and let it do it?

Any suggestion or tip is more than welcome.

Cheers,  
Jose

---

<div class="post-metadata">

**Author:** ![jcaballero](https://avatars.discourse-cdn.com/v4/letter/j/278dde/32.png) [@jcaballero](https://discuss.elastic.co/u/jcaballero)\
**Post date:** [April 26, 2019, 8:46pm UTC](https://discuss.elastic.co/t/writing-my-own-filter-plugin-what-is-the-best-way-to-implement-the-regex-matching/178328/2 "2019-04-26T20:46:58Z")

</div>

from the lack of comments, I deduce the answer is (1): implement the regex matching in the code from scratch.

---

<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:** [May 24, 2019, 8:46pm UTC](https://discuss.elastic.co/t/writing-my-own-filter-plugin-what-is-the-best-way-to-implement-the-regex-matching/178328/3 "2019-05-24T20:46:59Z")

</div>

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