Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page

# Revision history [back]

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 https://regex101.com/ 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.

## Examples

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)