You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2023/01/19 01:44:46 UTC

[GitHub] [netbeans] mbien commented on a diff in pull request #5311: Replaced replaceAll() calls to replace()

mbien commented on code in PR #5311:
URL: https://github.com/apache/netbeans/pull/5311#discussion_r1080731688


##########
ide/bugtracking.bridge/src/org/netbeans/modules/bugtracking/vcs/HookUtils.java:
##########
@@ -43,16 +43,10 @@ public class HookUtils {
      * @return
      */
     public static String prepareFormatString(String formatString, String... keys) {
-        formatString = formatString.replaceAll("\\{", "'\\{'");                 // NOI18N
-        formatString = formatString.replaceAll("\\}", "'\\}'");                 // NOI18N
-        for (int i = 0; i < keys.length; i++) {
-            String key = keys[i];
-            formatString =
-                formatString.replaceAll(
-                    "'\\{'" + key + "'\\}'",                                    // NOI18N
-                    "\\{" + i + "\\}"                                           // NOI18N
-                );
-
+        formatString = formatString.replace("{", "'{'");                 // NOI18N
+        formatString = formatString.replace("}", "'}'");                 // NOI18N
+        for (String key : keys) {
+            formatString = formatString.replace("'{'" + key + "'}'", "{" + key + "}");
         }

Review Comment:
   second `key` should be `i` but you removed the index from the loop, so you have to revert that too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists