I am coding a C project and as I am unexperienced, everytime I needed to access the element of a pointer to a struct I typed (*x).y
(where x is a struct and y an item), which I just realized could be rewritten as ->
which would look much nicer. So I first tried to make a regular expression to find all such occurences. I thought /(/*.+/)/.
would work, but it gave some strange unwanted occurences. For example (queue_t *queue)
would match which I don't understand why.
I'm also unsure what macro could be used if I got the correct regex. I thought making then a macro which deletes the first 2 characters, and then would go to the "end" to replace ).
with ->
, but then if I have something of the type (*(*a).b)).c
I don't know how to find the correct )
.
Also are there better alternatives to do what I want other than use regular expressions and macros?