# Regex - Can you return the matched pattern using sub?

**URL:** <https://community.zeek.org/t/regex-can-you-return-the-matched-pattern-using-sub/5806>\
**Category:** Zeek\
**Created:** [August 14, 2019, 7:08pm UTC](https://community.zeek.org/t/regex-can-you-return-the-matched-pattern-using-sub/5806 "2019-08-14T19:08:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonah\_Burgess](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@Jonah\_Burgess](https://community.zeek.org/u/Jonah_Burgess)\
**Post date:** [August 14, 2019, 7:08pm UTC](https://community.zeek.org/t/regex-can-you-return-the-matched-pattern-using-sub/5806/1 "2019-08-14T19:08:06Z")

</div>

Furthermore, is there an alternative to match\_pattern that returns all matches for a pattern?

It would probably help if I could more better documentation about regex functions in Zeek… I have this: [https://docs.zeek.org/en/stable/scripts/base/utils/patterns.bro.html](https://docs.zeek.org/en/stable/scripts/base/utils/patterns.bro.html) but if anybody could recommend more resources it would be appreciated.

Thanks,

Jonah

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:46pm UTC](https://community.zeek.org/t/regex-can-you-return-the-matched-pattern-using-sub/5806/2 "2022-05-06T15:46:42Z")

</div>


