Regexp use for text transformation with Intellij

Given a snippet of code such as:
put("item123", x);
put("item456", x);
....
put("item888", x);


                
To retrieve the content in between quotes:
item123
item456
...
item888


Then this can be achieved using the in-place find and replace functionality offered by Intellij.
(obviously a manual edit would also work, but might not be as efficient if the block of code is repeated 1000 times).


1. search for the regex put\("


2. replace the selection with an empty field, this yields:

item123", x);
item456", x);
....
item888", x);


3. search for the regex \".+  (select everything extending from the first quote to the end of the line)


4.replace the selection with an empty string yields: 

item123
item456
....
item888

No comments:

Post a Comment