11-22-2017 06:42 AM - edited 11-22-2017 06:44 AM
I'm using LabView2017, and I've read http://zone.ni.com/reference/en-XX/help/371361P-01/lvhowto/regular_expression_patterns so I think I know what the docs *claim* LabView supports. It isn't working though, so I'm looking for feedback on what I'm missing.
I'm putting together a front end for tests. Some of the tests are copy-and-pastes of controls, so I'm wanting to search-and-replace the control names when I copy them. For an example, if I copy a control named " "5.8-2.13. Passed", LabView will name the copied version "5.8-2.13. Passed 2", and I want to search-and-replace that to "5.8-3.13. Passed".
My search regex is "(5\.8-2\.)([0-9]+)(\. Passed 2)" and my replace is "5.8-3.$2. Passed". I've used http://www.regexe.com/ to double-check that both are correct. LabView correctly finds all instances of "5.8-2.<number>. Passed 2", but what I actually get when I do "Replace" is the literal text "5.8-3.$2. Passed".
Basically it looks like in spite of the "Find" being set to use regex, the "Replace" only goes for a regular string. I've looked around but there's no information in Help or in the online docs (linked page) about how to make this happen - everything says that if you select "Regular expression" in the "Find" then it'll just work in the "Replace". Except it just flat doesn't.
I've tried escaping the dots in the replace string, removing the match strings before and after in the find regex, adding "{}" around the backreference number, even just using "$1" or "$2" on its own as the replace string. Nothing works - everything simply pastes in that literal text without attempting to regex-replace it with the backreference.
What am I missing here? Have I misunderstood the docs and LabView actually can't do a regex search-and-replace?
11-24-2017 01:57 PM - edited 11-24-2017 02:14 PM
I can't test on my tablet, but will try to get you further.
You might post a vi so it's easier for people to help.
Just to see if it works, and because it's easier, could you try "5\.8-2\.([0-9]+)\. Passed 2" and replace is "5.8-3.$1. Passed".
I have an itch in the back of my head that tells me to use \3, not $3. Might be something to try, just to humor me. EDIT: That's not it.
I've done similar expressions in LabVIEW 2013, and I'm inclined to say it show work like you expect. If you have other LV versions, you could try it in those versions.
Might try this all myself on Monday, if I didn't forget about it by then (that is what the weekend is for after all). EDIT: couldn't help myself...
11-24-2017 02:11 PM
OK, couldn't help myself.
It works fine in LV2013. See attached VI.
This means:
the regex is fine.
the replace string is fine.
LabVIEW 2013 is fine.
Only thing that remains is your VI, and LV2017...
11-24-2017 03:16 PM
11-29-2017 01:22 PM - edited 11-29-2017 01:23 PM
Thanks, wiebe@CARYA and ben.
Your VI shows you just doing a search-and-replace on a string though. Sorry if I wasn't clear - what I'm trying to do is search-and-replace the names of controls (and indicators). So from the LV menu:-
Doing this, LV simply pastes the replace text into those labels as-is, without using the regex replacement rules.
11-30-2017 02:59 AM - edited 11-30-2017 03:06 AM
Yes, that doesn't work (bold language would be in place, but I resisted).
See this idea:
And on the same subject:
https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-Match-Regular-Expression-sub-VI/idi-p/3699605
Doesn't seem to bother many people (nobody but me so far), so I guess we're out of luck. Unless there are >30 kudo's it's unlikely to happen.
Just to make sure: if you give kudo's to the idea(s), it might be in LabVIEW someday.
And feel free to post a comment on the ideas how much of a missed opportunity this is (it's an outrage if you'd ask me).
11-30-2017 05:00 AM
Thanks for the confirmation - at least I know it's broken by design, and not me doing something daft. ("Dead lightbulb is a feature.") Like you say, since regex is a thing, it shouldn't be rocket science to put another checkbox on the "replace" side of things and use the same off-the-shelf regex library that they're using for "find".
11-30-2017 05:12 AM
@grab wrote:
Thanks for the confirmation - at least I know it's broken by design, and not me doing something daft. ("Dead lightbulb is a feature.") Like you say, since regex is a thing, it shouldn't be rocket science to put another checkbox on the "replace" side of things and use the same off-the-shelf regex library that they're using for "find".
I've been to the same process when I started appreciating regular expressions. Couldn't believe they missed the opportunity! It makes so much sense to have this feature.
I've posted a link to this thread from the idea exchange (hopefully it will act as a "ping").
Tanks for the kudo's!