[Solved] Netclasses Regexp (slash Wildcard) field

Where do I find info on how the regexp for the Netclasses works?
It doesn’t look like something that I ever used.

The expressions should start with the full path (in the case of hierarchical sheets) or * if you don`t care.

Also, I could not use something like this

*USB*D[+-] to filter things like:


What does this mean?
Does it require a special format to use one or another, or this means they are kind of the same thing?

I can see the wildcards work. But it is not a regexp, at least as far as I know.

For instance, here.
I want to select those 4 signals on the right (excluding the unconnected)

This would be quite trivial with regexp.

I believe that right now only the Wildcard * is working.

I can only hope this would be more clear after reading the thread I linked, but I don’t think it will be. As was said there, the pattern is tried as both (regexp and wildcard), and if either style matches, it’s a match.

EDIT: if this helps:

  • Net name is put through regular expression pattern matching engine with your pattern. If the net name matches the pattern interpreted as regular expression pattern, the net name matches your pattern.
  • Net name is also put through wildcard pattern matching engine with your pattern. If the net name matches the pattern interpreted as wildcard pattern, the net name matches your pattern.

It’s inclusive OR, i.e. one or both can be true for the result to be true, and the order of the tests doesn’t matter.

1 Like

Alright, I could achieve the desired thing with this, but this is not reliable because if the signal ends with D1 or anything that is not + or - it will match.

I think you can do pretty much anything with regexp. Wildcard matching is very simple. Regexp requires actually learning the syntax.

I could not make any regexp yet.

Do you know how do you make a pattern that matches anything that ends with + or -?

Netclasses - Wildcards - #4 by itsko tells that the syntax is here: wxWidgets: Regular Expressions. I’m not a regexp expert, maybe someone else can help. It really wouldn’t hurt to have examples in KiCad documentation for common cases… the naming style used in net names is usually limited and similar patterns would be often found.

This is not working.
Here is another example.

I have 2 regexps

  • *ENET_*D? which finds the wires (in the Schematic Setup)… but does not mark the wires in the schematic (they should be Red)
  • *ENET_BIAS? this one finds the wire ENET_BIAS and makes it Red.

All the ENET_*D? and the ENET_BIAS should be red because they were being added by the Wildcard/Regexp

Now, this time, when I add the net class with the toolbar button, then it adds.

oh, this does not work for me.

this neither

this works with the

this also works with ? since it is a single character

You are using a single-sheet project, I think. i am using multi-sheet. Do you think it may be related? I ma going to check.

You are also using global labels…

I checked the bottom of the page, and the wires I want to filter have the right name.

You need to go look at some regex reference documentation if you want to understand why what you tried doesn’t work. You’re looking for .*USB_conn_D[+-] for local labels.

First of all, a new project with a single page.

I always have to use the first * otherwise it won’t show anything.

Dude, I am not crazy, there is something wrong. At least on Linux.

Application: KiCad Schematic Editor x86_64 on x86_64

Version: 7.0.5-4d25ed1034~172~ubuntu23.04.1, release build

	wxWidgets 3.2.2
	FreeType 2.12.1
	HarfBuzz 6.0.0
	FontConfig 2.14.1
	libcurl/7.88.1 OpenSSL/3.0.8 zlib/1.2.13 brotli/1.0.9 zstd/1.5.4 libidn2/2.3.3 libpsl/0.21.2 (+libidn2/2.3.3) libssh/0.10.4/openssl/zlib nghttp2/1.52.0 librtmp/2.3

Platform: Ubuntu 23.04, 64 bit, Little endian, wxGTK, ubuntu-xorg, x11

Build Info:
	Date: May 27 2023 23:08:39
	wxWidgets: 3.2.2 (wchar_t,wx containers) GTK+ 3.24
	Boost: 1.74.0
	OCC: 7.6.3
	Curl: 7.88.1
	ngspice: 38
	Compiler: GCC 12.2.0 with C++ ABI 1017

Build settings:

Wait, what?

. for local labels. this is confusing. since .` is a regexp command.

Yes… I’m giving you a regular expression to solve your problem. You can’t do the thing you want with wildcards (select the ones ending in +/- but exclude the ones ending in something else).

Nothing is wrong: putting in USB* won’t match any local labels because all local labels start with a sheet path (/ on root sheet, etc)

Sure, I don’t want to use wildcards. I want to use regexp. But the regexp was not working.
Now, with the dot in front, it looks like it worked. I am going to neeto to test it more.

But the dot in regexp means this:

Alright, that makes sense, thanks. But I still have one extra issue… let me get another example.

Here I am on another sheet that is not the Root.

Ok, got it.
This dot in front does all the magic.
If I use * directly I am using wildcard instead of regexp, and this is messing up with my pattern.

thanks @craftyjon all good now!