diff --git a/src/com/google/javascript/jscomp/StripCode.java b/src/com/google/javascript/jscomp/StripCode.java
index <HASH>..<HASH> 100644
--- a/src/com/google/javascript/jscomp/StripCode.java
+++ b/src/com/google/javascript/jscomp/StripCode.java
@@ -283,7 +283,8 @@ class StripCode implements CompilerPass {
         String name = nameNode.getString();
         // If this variable represents a collapsed property, it's the original property name we're
         // supposed to be matching against.
-        String possibleStripName = name.contains("$") ? name.replaceAll(".*\\$", "") : name;
+        int lastDollarSign = name.lastIndexOf('$');
+        String possibleStripName = lastDollarSign != -1 ? name.substring(lastDollarSign + 1) : name;
         if (isStripName(possibleStripName)
             || qualifiedNameBeginsWithStripType(nameNode)
             || isCallWhoseReturnValueShouldBeStripped(nameNode.getFirstChild())) {
Replace expensive String::replaceAll with cheap .substring call

PiperOrigin-RevId: <I>