I want to copy past a huge list of properties rather than type them all out again. However I want to avoid copy their assignments.
The solution I’m trying involves a cmdF regex in VSCode. Then selecting all found matches.
Sample of typescript code.
this.anchorBillingAddress = this.page.getByTestId('billing-address-section');
this.anchorShippingAddress = this.page.getByTestId('shipping-address-section');
this.anchorBilling = this.page.getByTestId('billing-section');
this.anchorGeneral = this.page.getByTestId('general-section');
this.anchorStatistics = this.page.getByTestId('statistics-section');
this[^s]+
is what I have tried. However it ends up copying the assignment as well. How do I make it stop at the first white space encountered in each line?
2
Answers
You can use
s*b(this.[^;]+s*;)
ors*b(this.[^;]+)s*;
, which captures the entire line.Note:
s*
: 0 or more space.b
: word boundary.(this.[^;]+s*;)
: captures fromthis.
to the end of the first;
, which I assume that’s what you want.If you want it to stop at the first space, you can do this
^this[^s]+
The
^
makes sure it’s from the start and won’t grab the secondthis
.