I was reading this topic: viewtopic.php?f=32&t=5360#p19963 where Andrew demonstrated selective selection with the selection filter and a simple regex: "[A-Z]+[0-9]+" (no quotes used in QCAD). I'm not getting the same results, though. I tried it on an existing drawing and after seeing a difference, created a very simple test drawing with the same text he used in that post: ABC123, 123ABC, 123, ABC.
[A-Z]+[0-9]+, [A-Z]+ and [0-9]+ all select everything (all four text entities) -- The purely-numeric "123" is matched by [A-Z]+ and the non-numeric "ABC" is matched by [0-9]+. If I change A-Z to a-z, of course nothing gets selected at all, since this is a case-sensitive regex. Using + instead of * should force the presence of at least one matching character, but it doesn't appear to be happening with the [A-Z]+ and [0-9]+ patterns in my drawing.
I'm no deep expert with regexes in general but this looks pretty straightforward. Why does everything get selected even with or without the alpha/numeric tags? I'm deselecting everything and clicking the Replace Selection button for each test, so that should rule out any previous selection. I even tried a couple of different fonts, but no change. What have I done (or configured?) in this drawing to make QCAD see no difference between alpha/num?
3.19.2 on Xubuntu 16.04, 64-bit
Thanks.
Regexes in selection filter
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Regexes in selection filter
- Attachments
-
- Text_selection_test.dwg
- (18.05 KiB) Downloaded 288 times
Len
QCAD Pro
QCAD Pro
Re: Regexes in selection filter
The regular expression is applied to the source of the text, not only the visible part.
The sources of your (formatted) text entities are:
\H0.125;123ABC
\H0.125;123
\H0.125;ABC123
\H0.125;ABC
The H0 bit matches your regexp.
The sources of your (formatted) text entities are:
\H0.125;123ABC
\H0.125;123
\H0.125;ABC123
\H0.125;ABC
The H0 bit matches your regexp.
Re: Regexes in selection filter
So does that mean it can only be "trusted" to be accurate on non-formatted text? I assumed (?) by changing to the standard (non-TrueType) font it wouldn't have any formatting information. How do we make it work against only the actual textual part of a text label?
By the way, I'm just curious, not critical, since it would seem to seriously impact the usefulness of regex searches (not to mention increase the complexity of regex expressions) if formatting strings have to be taken into account.
Thanks.
By the way, I'm just curious, not critical, since it would seem to seriously impact the usefulness of regex searches (not to mention increase the complexity of regex expressions) if formatting strings have to be taken into account.
Thanks.
Len
QCAD Pro
QCAD Pro
Re: Regexes in selection filter
It means you can use it not only to look for visible text, but also to look for formatting inside text (which is a good thing and an important feature). Think selection of all texts containing subscripts or all texts containing italic formatting, etc.lphilpot wrote:So does that mean it can only be "trusted" to be accurate on non-formatted text?
If you want to only look for displayed text (visible text), use the property Plain Text instead of Text.
No, CAD line fonts have nothing to do with formatting.lphilpot wrote:I assumed (?) by changing to the standard (non-TrueType) font it wouldn't have any formatting information.
If you don't want to use any formatting (line feeds, color changes, subscript, superscript, fat, italic, font changes, etc.), tick simple text in the text dialog or in the property editor. This is recommended for all single line texts without formatting.
Re: Regexes in selection filter
That makes sense. You don't have to convince me of the usefulness of regular expressions (as I come from a *nix background).
Thanks.
Thanks.
Len
QCAD Pro
QCAD Pro
Re: Regexes in selection filter
Me too!lphilpot wrote:... as I come from a *nix background.
Most of the time I work with the much "less fancy" Find/Replace tool below the Edit menu. Simple is good for me ...
Work smart, not hard: QCad Pro
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."
Win10/64, QcadPro, QcadCam version: Current.
If a thread is considered as "solved" please change the title of the first post to "[solved] Title..."