03-06-2014 10:48 AM
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,/"
03-06-2014 11:00 AM
03-07-2014 02:06 AM
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.
03-10-2014 08:21 AM
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?
03-11-2014 05:07 AM
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