Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Regular Expressions to filter Output:Variable

asked 2015-11-17 11:35:15 -0500

updated 2023-03-22 13:06:59 -0500

In the "Key" field of the Output:Variable, is there any way to wildcards (aside from "*" by itself), or even regular expressions?

Output:Variable, *, !- Key Value System Node Temperature, !- Variable Name hourly; !- Reporting Frequency

For example, I might want to output the System Node Temperature only for all nodes that contain either 'DOAS' or 'DHW'. Is that possible?

edit retag flag offensive close merge delete


Good question, Unless something has changed I don't think it is possible. But since I don't know I'll just leave this as comment. If using OpenStudio you could enahcne the add output variable measure to search and create multiple 'Output:Variable' objects.

David Goldwasser's avatar David Goldwasser  ( 2015-11-17 13:02:37 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-11-17 19:09:46 -0500

No this is not possible at this point, but it is a great User Voice suggestion. Thanks to @Eric Ringold for finding the spot, you can see in the source code that it only accepts the variable name or "*".

That said, I think adding a true wildcard or regular expression looks possible (on the surface). So add this as a suggestion on User Voice.

edit flag offensive delete link more


Here is the User voice request

Julien Marrec's avatar Julien Marrec  ( 2015-11-18 02:25:08 -0500 )edit

Are there any examples of using regular expressions for filtering output variables?

kwalkerman's avatar kwalkerman  ( 2018-07-13 16:44:43 -0500 )edit

@kwalkerman: added an answer to update the status of the thread + show examples as you requested. Thanks to @MarkAdams for this really useful feature!

Julien Marrec's avatar Julien Marrec  ( 2018-07-16 02:50:23 -0500 )edit

answered 2018-07-16 02:49:42 -0500

Support for regular expressions (regex) has been added by @MarkAdams in PR#6017, circa E+ 8.7.

The I/O reference guide shows a simple example of a regex for Key Value here and links to a page showing the Regex flavor that is being used: google/re2.

It also mentions that no regex can contain a comma , even if it is valid regex syntax (eg: between 2 and 5 digits, \d{2,5}, isn't valid).

Even though there isn't support for re2 regex flavor, I strongly recommend as a test bed. It's a website that I wished existed when I got started with regexes, as it allows to quickly test your regex, and will decompose the behavior or a given regex.


I'll give some fresh examples, because more is better.

If given the following nodes:

SalesFloor InletNode 1
SalesFloor InletNode 2
SalesFloor InletNode 3
Office InletNode 1
Office InletNode 2
Office InletNode 3
SalesFloor OutletNode 1
SalesFloor OutletNode 2
SalesFloor OutletNode 3
Office OutletNode 1
Office OutletNode 2
Office OutletNode 3

Select all SalesFloor's inlet Nodes

SalesFloor InletNode \d+

(\d+ means any digit, one or more, prefer more (=greedy))

Select all SalesFloor's inlet and outlet nodes

SalesFloor (Inlet|Outlet)Node \d+

All Inlet Nodes only

.*InletNode \d+

.* means any character, zero or more times, greedy.

All first two inlet nodes

.*InletNode [1-2]

Select all InletNodes numbered below 100

Typically, you would do .*InletNode \d{1,2}. But like the I/O said, you can't use a comma. So you have to explicitly list the digits here: we want at least one, maybe two, that's it

.*InletNode \d\d*$

I'm not 100% sure the $ = end of text anchor is supported, but I think it is.

It isn't even required here because E+ uses RE2::FullMatch (see here) which requires the regexp to match the entire input text (as opposed to RE2::PartialMatch which looks for a match for a substring of the input text)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2015-11-17 11:35:15 -0500

Seen: 391 times

Last updated: Jul 16 '18