I have a regexp that sets $1 : it corresponds to the text between ( and ) in : the_beginning(.*)the_end.
I want to replace the value corresponding to $1 with somethingelse, not all the regexp.
In real context :
my_string contains :
/* MyKey */ = { [code_missing]; MY_VALUE = "123456789"; [code_missing]; }
I want to replace “123456789” ( with “987654321” for example ).
And this is my regexp :
"/\\* MyKey \\*/ = {[^}]*MY_VALUE = \"(.*)\";"
I’m still not sure exactly what you want, but here’s some code that should help you:
Edit:
Edit #2: Getting access to information before/after a match
Note that this requires a regex that does not actually match the pre/post text.
If you need to specify the limits, and not the contents, you can use zero-width lookbehind/lookahead:
…but now this is clearly more work than just capturing and using
\1and\2. I’m not sure I fully understand what you are looking for, why you think it would be easier.