I have this much
Code snippet:
int *filePointer;
float *valPtr;
*valPtr = 5.6;
filePointer = ∑
I would like to replace all pointer variables as follows, for example
- *filePointer have to be converted to *filePointer_p.
- filePointer have to be converted to filePointer.
- valPtr have to be converted to valPtr_p
How can I do it using Regular Expression.
It sounds to me like you might be asking how to use regular expressions as a generic tool to rename all pointer variables in source code. I am assuming that the provided snippet is just an example.
If my understanding of your goal is correct, it is not possible to do that with regular expressions. A regular expression would not be able to determine reliably from the context if a variable is a pointer. Consider, for example,
a=b;.aandbcould be pointers or they could be most anything else. A regular expression by itself would not be able to determine that.