please consider the following javascript code:
"myObject.myMethod();".replace(/\.\w+\(/g, "xxx");
it gives “myObjectxxx);” as “.myMethod(” is selected.
Now I would only select myMethod instead. In other words I want to select any word starting with . and ending with ( (excluded).
Thanks, Luca.
General answer: Capture the part that you want to keep with parentheses, and include it in the substitution string as
$1.See any regexp substitution tutorial for details.
Here: just include the
.and the(in your substitution string.For an exercise, write a regexp that will turn any string of the scheme
--ABC--DEF--to--DEF--ABC--for arbitrary letter-values ofABCandDEF. So--XY--IJK--should turn into--IJK--XY--. Here you really need to use capture groups and back references.