LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Regex replacement syntax in editor

Hello all,

for the life of me I can't remember (nor find in the documentation) the syntax for doing string replacements using regular expressions in the CVI editor.

Something like:

Search: ({[~,]*},

Replace: (\1, A10,

Would change the string "(aei1," to "(aei1, A10,"

But what are the delimiters to use ? {} like in my example ? And what's the variable ? \1 ? $1 ?

I just can't find it.

 

In sed syntax:

sed -e "s/(\([^,]*\),/(\1, A10,/"

0 Kudos
Message 1 of 5
(4,246 Views)
0 Kudos
Message 2 of 5
(4,243 Views)

No, it's not in there. Here's the relevant doc from sed for what I want:

       s/regexp/replacement/
              Attempt to match regexp against the pattern space.  If successful, replace that portion  matched  with  replacement.   The replacement  may contain the special character & to refer to that portion of the pattern space which matched, and the special escapes \1 through \9 to refer to the corresponding matching sub-expressions in the regexp.

I'm sure I've used it with the CVI editor before.

0 Kudos
Message 3 of 5
(4,224 Views)

Take a look at this stack overflow post: http://stackoverflow.com/questions/8044081/how-to-do-regex-string-replacements-in-pure-c

 

Is that what you're looking for?

Kelsey W.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 5
(4,191 Views)

Well, no, I was just looking to do it in the CVI editor. It's OK, I just used a perl one-liner on my source code and changed all the lines I wanted. I used the following to add an argument to a function:

perl -i -p -e 's/MyFunc([^,]*,[^,]*),/C\1, NEWARG,/g' *.c

 

0 Kudos
Message 5 of 5
(4,183 Views)