Are custom rules supposed to evaluate regular expressions?

Hi all!

I just came across something I did not expect. I assumed, as wildcards are supported within the custom rule constraint regexs would also be evaluated. I do have a number of netclasses Cell0 to Cell16 which I want to be matched vs. each other. Something like this, regex would be very helpful, but does not work:

(rule "Clearance: All cell inputs vs. everything (outer layers)"
   (layer outer)
   (constraint clearance (min 0.6mm))
   (condition "A.NetClass == '^Cell_{([0-9]|1[0-6])}'"))

(rule "Clearance: Cell input 5 vs. close potentials (outer layers)"
   (layer outer)
   (constraint clearance (min 0.2mm))
   (condition "A.NetClass == 'Cell_{5}' && (B.NetClass == '^Cell_{[1-9]}')"))

I thought this might be a problem with my regex-abilites.

But then I checked the clearance resolution for a simpler rule. Wildcards are accepted:

  • Layer F.Cu
  • Zone [/C_{E09}] on F.Cu [netclass Cell_{0}]
  • Zone [/CVTIN1/D] on F.Cu - B.Cu [netclass Cell_{1}]

Checking rule condition “A.NetClass == ‘Cell_{*}’”.
Rule applied; overrides previous constraints.

The same rule with regular expression does not seem to be recognized:

Checking rule condition “A.NetClass == ‘^Cell_{([0-9]|1[0-6])}’”.
Condition not satisfied; rule ignored.

A simpler “Cell_{[0-9]*}” does not work either. Is that the way it is supposed to work at the moment? :slight_smile: Do i make any mistake?

Thank you in advance!

Application: KiCad PCB Editor x86_64 on x86_64

Version: 7.99.0-1.20230620git21f2f98.fc38, release build

Libraries:
	wxWidgets 3.2.1
	FreeType 2.13.0
	HarfBuzz 7.1.0
	FontConfig 2.14.2
	libcurl/8.0.1 OpenSSL/3.0.9 zlib/1.2.13 brotli/1.0.9 libidn2/2.3.4 libpsl/0.21.2 (+libidn2/2.3.4) libssh/0.10.5/openssl/zlib nghttp2/1.52.0

Platform: Fedora release 38 (Thirty Eight), 64 bit, Little endian, wxGTK, gnome, wayland

Build Info:
	Date: Jun 20 2023 17:16:34
	wxWidgets: 3.2.1 (wchar_t,wx containers) GTK+ 3.24
	Boost: 1.78.0
	OCC: 7.6.3
	Curl: 8.0.1
	ngspice: 40
	Compiler: GCC 13.1.1 with C++ ABI 1018

Build settings:

There isn’t anything in the docs (on a quick skim) about regex, so my guess is this just hasn’t been implemented. The asterisk wildcard is also not clearly documented, but it has been used much more commonly (and appears in the examples).

If this is a feature you’d use a lot, definitely make an issue on Gitlab suggesting it! There may be some tricky stuff needed for this one to continue to support the asterisk wildcard along with Regex (the net class assignment allows either and it is currently being looked at for improvement).

If you do make an issue, please link it back to this forum post so that others who come across it can give it a “thumbs up” to show support.

1 Like

I also had a look at the docs, and the querstions about using regexs for assignment of nets to netclasses. As the rule evaluation does not change (just my expectation) but one which nets/netclasses are cosidered one could use the same logic. What I could imagine as a roadblock might be keeping ruke priorities consistent.

Thanks for your answer. This is very helpful for me :-). I will create a feature request as I do think this has quite some potential to simplify things. Here, the rules condititions will become rather long and a lot of manual labour… :clock9:

Edit: Issue tracker

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.