Regex syntax to check prefixes and suffixes

328 views Asked by At

I'm building some regex expressions to match naming conventions in Sigasi Studio (which uses Java syntax for regex). For example, a port name must end in _i or _o - e.g. my_input_port_i

I tried using the txt2re generator, however instead of a simple expression it generated code.

Looking at regex syntax, it seems that the "$" character (end of line) and the "|" symbol (OR) could be helpful - something like $_i|_o but after testing with regex101.com no matches are found.

Naming convention dialog:

Sigasi Studio Naming Conventions

2

There are 2 answers

1
Hendrik On BEST ANSWER

In Sigasi Studio the entire name should match. So your are looking for:

.*_[io]
1
The fourth bird On

The $ means end of the string, but you use it at the beginning.

Maybe you are looking for this at the end of the string, which uses an underscore _, then a character class to match i or o and then matches the end of the string $

_[io]$