# Format of Session Key Event RegEx

**URL:** <https://forum.inductiveautomation.com/t/format-of-session-key-event-regex/61086>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 22, 2022, 9:53pm UTC](https://forum.inductiveautomation.com/t/format-of-session-key-event-regex/61086 "2022-06-22T21:53:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [June 22, 2022, 9:53pm UTC](https://forum.inductiveautomation.com/t/format-of-session-key-event-regex/61086/1 "2022-06-22T21:53:45Z")

</div>

[This page of the manual](https://docs.inductiveautomation.com/display/DOC81/Perspective+Session+Event+Scripts#PerspectiveSessionEventScripts-KeyEvents) discusses the Session Key Event RegEx option, but there aren’t many specifics on the regex language. Is there somewhere I can read about the required pattern? It doesn’t appear to match the python regex syntax, exactly.

I’d like to accept three specific key presses `><z` followed by a number of digits (between 3 and 9) followed by a new line.

For a specific number of digits (5), this regex works, but I can’t figure out how to do a variable length.

`><z[0-9]{5}`

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 22, 2022, 10:02pm UTC](https://forum.inductiveautomation.com/t/format-of-session-key-event-regex/61086/2 "2022-06-22T22:02:24Z")

</div>

The key event regex is being executed on the frontend, so start your research from “Javascript regex” or “EMCAScript regex”. For a practical starting point, I can’t recommend `regex101.com` highly enough. E.G. for your example, I’d probably start from something like this:

> **[regex101: build, test, and debug regex](https://regex101.com/r/8tjIwh/1)**
>
> Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.

Do note that for…complicated reasons, if you want to detect an enter keypress, you need to literally capture `Enter` in your pattern. More on that here: [Perspective Key Event Regex New Line](https://forum.inductiveautomation.com/t/perspective-key-event-regex-new-line/51553)

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [June 22, 2022, 10:14pm UTC](https://forum.inductiveautomation.com/t/format-of-session-key-event-regex/61086/3 "2022-06-22T22:14:06Z")

</div>

Thanks for getting me started. Down the rabbit hole I go!
