Regular expressions look cryptic at first, but in QueueMetrics they can save you a lot of clicks: they let you find exactly the calls you are after, stop agents from typing a wrong code, and group queues into teams without listing them one by one. This guide collects the places where QueueMetrics accepts a regular expression, with examples you can copy and adapt.

Using regular expressions in QueueMetrics for fun and profit

A regular expression (regexp) is a compact way of describing a pattern of text: “three digits”, “anything starting with team1-”, “a number that is not an internal extension”. QueueMetrics is written in Java, so it uses Java-style regular expressions.

In QueueMetrics a regexp can be used in three main places:

  1. In reports, to find calls
  2. In the Agent Page, to help agents input valid codes
  3. In queue definitions, to group queues, for example into teams

We will also see how to test any pattern online before putting it in production.

A 2-minute refresher

You do not need to be an expert. These building blocks cover most of what you will ever need:

Pattern Meaning Example
^ Start of the text ^SIP matches “SIP/101” but not “my SIP”
$ End of the text 101$ matches “SIP/101” but not “1010”
. Any single character 1.3 matches “123” and “1x3”
\d One digit \d\d\d matches “304”
\d+ One or more digits ^\d+$ matches only numbers
\d{3} Exactly three digits ^\d{3}$ matches “304”, not “30”
* Zero or more of the previous item ^team.*
+ One or more of the previous item \d+
? Zero or one of the previous item ^\+?39 matches “39” and “+39”
[...] One character out of a set [123] matches “1”, “2” or “3”
(a\|b) Either a or b ^(sales\|support)$
(?!x) “Not followed by x” ^(?!_).+ matches anything not starting with an underscore
(?i) Ignore upper/lower case (?i)^sip/

TIP: when a pattern is meant to describe a whole value, always include the start (^) and end ($) anchors. Without them, a partial match is enough, and 10 would also match “1000” and “2105”.

Regexps to find calls

The Report Page lets you refine the calls shown by adding filters to the filter expression. Most filters that accept a text value also accept a regular expression.

The rule is simple: if the value starts with ^, QueueMetrics treats it as a regular expression. Anything else is searched as a plain substring.

Filters that are typically used with a regexp are:

  • Caller: the caller-id of the call
  • Agent: the agent code
  • Asterisk call-id: the Unique-Id of the call
  • Call variables: the value of a custom variable (more on this below)

How to add one

  1. Open a report and click Add Filter at the bottom of the recap panel.
  2. Look for the filter you want, for example Caller.
  3. Type the expression, starting with ^, and click the plus icon.

Since QueueMetrics 26.01, a regexp filter can also be changed afterwards: click the filter, select Edit Filter, change the pattern and apply it again with the plus icon, without recreating it.

As with any filter, you can also select Negate This Filter to get all the calls that do not match.

Examples

What you want Filter Pattern
Only internal calls (3-digit extensions) Caller ^\d{3}$
Only calls from numbers made of digits Caller ^\d+$
Calls from the Italian prefix, with or without + Caller ^(\+\|00)?39
Calls from a specific area code, skipping the first two digits Caller ^..393
Agents from 200 to 299 Agent ^2\d\d$
Agents 101, 105 and 110 Agent ^(101\|105\|110)$
Recordings of a given PBX that end in .0 Asterisk call-id \.0$

NOTE: the area code example (^..393) comes straight from the QueueMetrics manual: the two dots skip the first two digits, and 393 must follow.

Filtering by call variables

If you track custom variables on your calls, the Variables filter lets you check several of them at once, and each value can be a regexp:

  • A B C means that all three variables must be present on the call
  • A:12 B: means that variable A must be 12 and B must be present
  • A:^x. means that the value of A must match the regular expression ^x., for example “xy” but not “qqq”

Use “negate” to your advantage

Writing a pattern that matches what you do not want is often harder than writing one for what you do want. In that case, write the simple pattern and negate the filter: for example, to hide internal calls, filter by Caller ^\d{3}$ and mark it as negative.

NOTE: users holding the HIDE_NUMBERS key see telephone numbers masked, so filters and features that depend on the numbers may not give reliable results for them.

Regexps to help input (Agent Page)

Typing a wrong agent code or a wrong extension is one of the most common causes of “ghost” agents in the reports. The Agent Page can check what agents type before sending it to the PBX, so that wrong values are rejected right away.

This is controlled by two system parameters. Open Edit System Parameters and set:

# Allowed agent codes
realtime.agentRegexp=2\d\d

# Allowed extensions
realtime.extensionRegexp=3\d\d

With these settings:

  • agent codes must have three digits and start with 2 (such as 201, but not 301 or 20);
  • extensions must have three digits and start with 3 (such as 305, but not 405 or 30).

Any other value is refused in the login, logoff and pause panels.

Property What it validates Example
realtime.agentRegexp Agent codes the agent can enter 1\d\d
realtime.extensionRegexp Extensions the agent can enter \d\d\d

TIP: a related setting is default.lockedAgentPopupCode. If set to true, agents cannot change their code in the login, logoff and pause pop-ups at all, which is the safest choice when the agent code is tied to the user.

Other places where a pattern helps with input

  • Recording file names: the llm.captureUniqueId property takes a regular expression that extracts the call’s Unique-Id from the name of a recording, so that transcriptions can be matched to their call. See the transcription tutorial for examples. For instance, ^.*-(.+)\.[^.]+$ takes everything from the last dash to the last dot.
  • Uniloader: some Uniloader options accept a regexp for queues and agents, for example to ignore or target a given set of them. For these, the Uniloader manual suggests always using the start and end anchors, and enclosing the expression in single quotes in your shell. Examples are ^(301|302)$ (queues 301 or 302 but not 303) and ^.+?/\d+$ (any agent like “SIP/123”).

Regexps to filter queues (build your teams)

In QueueMetrics each queue entry on the Home Page has an Alias, which is the name users see, and a Composition, which says which real queues are behind it. Composition can be one queue, a list separated by the pipe symbol (queue1|queue2|queue3), or a pattern.

This is the easiest way to build teams: if your queues follow a naming convention, a single composition can gather all the queues of a team, and any new queue that follows the convention is included automatically.

Three kinds of pattern

Syntax Meaning Example
* Any number of characters open* matches every queue starting with “open”
? One single character open? matches “open1” and “openq”, but not “open99”
Starts with ^ A case-insensitive regular expression ^(?!_).+ matches every queue that does not start with an underscore

Example: one entry per team

Suppose your queues are named team1-sales, team1-support, team2-sales and team2-support. You can create these entries:

Alias Composition What it shows
Team 1 ^team1-.* All the queues of team 1
Team 2 ^team2-.* All the queues of team 2
All sales ^team\d-sales$ The sales queue of every team
Everything except hidden queues ^(?!_).+ All queues not starting with an underscore

NOTE: patterns work on the queues that are defined in QueueMetrics. A queue that exists on the PBX but has not been created in QueueMetrics will not be matched, even by *.

NOTE: a single hidden queue is matched by a non-hidden front-page queue that includes it, so you can keep technical queues out of the selector and still count them in a team.

Wildcards in other places

Some other settings accept a list of queues with wildcards, such as the queue visibility of a call outcome or of a QA form: queues are separated by spaces, and if the field is left blank the item is shown for all queues. Here you can use the * and ? wildcards to match several queues, or subqueues, at once.

Test your patterns before using them

Never test a pattern on a production system for the first time. A free online tester lets you try it against real values in seconds:

regexplanet.com - Java regular expression tester

Since QueueMetrics is a Java application, pick the Java flavour of the tool. To use it:

  1. Type your pattern in the Regular Expression box.
  2. Paste a few real values in the test box, one per line: some that should match and some that should not. For calls, use the real caller-ids; for queues, the real queue names.
  3. Run the test and check which lines match.
  4. Copy the pattern, without any quotes, in QueueMetrics.

TIP: the tool also shows the pattern as a Java string, where every backslash is doubled (\\d). That is only needed inside Java source code: in QueueMetrics, write the pattern with a single backslash, as in the examples in this guide.

Quick recipes

Goal Where Pattern
Calls from internal extensions only Report filter, Caller ^\d{3}$
Calls from external numbers only Report filter, Caller, negated ^\d{3}$
Numbers starting with a prefix Report filter, Caller ^0039
A group of agents Report filter, Agent ^(101\|102\|103)$
Agents in a numbering range Agent Page, realtime.agentRegexp 1\d\d
Only 4-digit extensions Agent Page, realtime.extensionRegexp \d{4}
All queues of a team Queue composition ^team1-.*
All queues except technical ones Queue composition ^(?!_).+
The Unique-Id from a recording name llm.captureUniqueId ^.*-(.+)\.[^.]+$

Troubleshooting

  • The pattern is taken as plain text: in reports and queue compositions, the value must start with ^ to be read as a regular expression.
  • Too many results: the pattern is probably not anchored. Add ^ at the start and $ at the end.
  • No results at all: check that special characters are escaped. A dot (.) means “any character”: use \. for a real dot, and \+ for a real plus sign.
  • Queue pattern matches nothing: patterns only match queues that are defined in QueueMetrics. Check that the queues exist, and that their names are exactly as you expect.
  • Upper and lower case: queue compositions are case-insensitive, but you should not rely on that elsewhere. If in doubt, add (?i) at the start, as in (?i)^sip/.
  • Agents are rejected at login: the value does not match realtime.agentRegexp or realtime.extensionRegexp. Test it with the same value in the online tester, and remember that agents must reload their page after you change the parameters.
  • It works in the tester but not in QueueMetrics: check that you did not copy the doubled backslashes (\\d) or the quotes from the tool.

QueueMetrics References

For more technical information about QueueMetrics call center solution please refer to the User Manual.

About QueueMetrics

QueueMetrics is a highly scalable monitoring software that lets you track agent productivity, payrolls, measure targets, conversion rates, queues/ACDs, IVRs, music-on-hold, generate outbound campaign statistics and monitor realtime processes with customizable wallboards.

You can measure all activities in your contact center with more than 200 different metrics and manage realtime processes with live alarms and full control on calls and extensions, including whisper, spy and barge modes.

QueueMetrics is available on premise or as a cloud hosted service, and it is compatible with FreePBX, Grandstream, Issabel, MiRTA, Enswitch, Yeastar S PBX, VitalPBX, FusionPBX and many other Asterisk- and Freeswitch-based systems. It also supports Microsoft Teams telephony.

For more technical information please refer to the User Manual.

Visit www.queuemetrics.com for a free 15-day full-featured trial.

keyboard_arrow_left Back