---
title: "Create a regular expression for the remote or local port that references a variable"
description: "Create a regular expression for remote or local ports by referencing a variable using the syntax $(VariableName). This method allows monitoring different ports on multiple managed entities with the same TCP-Link sampler."
url: "https://docs.itrsgroup.com/docs/faq/geneos/115004019785-geneos-create-a-regular-expression-for-the-remote-or-local-port-that-references-a-variable/index.html"
---
![Geneos - create a regular expression for the remote or local port that references a variable](https://docscdn.itrsgroup.com/faq/images/geneos/115004019785-remote-006-check-749104752d9a.png) Construct the regular expression as usual and use $() to enclose the variable name.

![Geneos - create a regular expression for the remote or local port that references a variable](https://docscdn.itrsgroup.com/faq/images/geneos/115004019785-remote-007-information-bd24afaa7dc8.png) To monitor a different remote port on 2 different managed entities using the same TCP-Link sampler with a variable name RemotePort:

The sampler below references the RemotePort variable as $(RemotePort) and the tailing $ in regex to look for this pattern at the end:

![8051379683613 mceclip2](https://docscdn.itrsgroup.com/faq/images/geneos/115004019785-8051379683613-mceclip2.png)

The managed entities have the variable defined as:

![8052040918941 mceclip5](https://docscdn.itrsgroup.com/faq/images/geneos/115004019785-8052040918941-mceclip5.png)

![8052042775453 mceclip6](https://docscdn.itrsgroup.com/faq/images/geneos/115004019785-8052042775453-mceclip6.png)

![8052044536349 mceclip7](https://docscdn.itrsgroup.com/faq/images/geneos/115004019785-8052044536349-mceclip7.png)


