Reputation: 6887
I just need to find and replace the following word set in VsCode
t("US.TL.PACKAGES:installmentDetail.discount")
I was tried a lot by following
(?:US\.TL\.PACKAGES:)([a-z])([A-Z])
but when I used
([a-z])([A-Z])
this captures all upper in the string.
I need to group by each new word.
installment Detail discount
To put underscore i'm using
\1_\2 in Replace
Final output
US.TL.PACKAGES:INSTALLMENT_DETAILS.DISCOUNT
Upvotes: 3
Views: 155
Reputation: 627327
The following can be used in the Search & Replace tool, not in the Find/Replace in Files feature (opened with Ctrl+Shift+F) because the latter uses another, old regex engine and the former uses the modern ECMAScript 2018+ compliant engine as in most major JavaScript environments:
US.TL.PACKAGES:
string:(?<=\bUS\.TL\.PACKAGES:\S*?[a-z])(?=[A-Z])
Replace with a mere _
. Make sure the Aa
option is checked as matching must be case sensitive:
US.TL.PACKAGES:
string uppercase:(?<=\bUS\.TL\.PACKAGES:\S*?)[A-Za-z]+
Replace with \U$0
.
and the result is
Upvotes: 2