title: Getting java.util.regex.PatternSyntaxException: Illegal repetition when trying to replace String with replaceAll()
body: <p>I am trying to match the words from the given string with regex </p>
  
  <pre><code>{{ some | value }}
  </code></pre>
  
  <p>like this.</p>
  
  <p>for example :</p>
  
  <pre><code>Hello {{ some | value }}, this is what i tried {{ another | value }}
  </code></pre>
  
  <p>from this i want to extract </p>
  
  <pre><code>{{ some | value }} and {{ another | value }}
  </code></pre>
  
  <p>I tried with this regex pattern <code>Pattern.compile("\\{\\{(.*?)\\}\\}")</code></p>
  
  <p>when i tried to iterate all the matches and replace using <code>replaceAll</code> i got <code>java.util.regex.PatternSyntaxException: Illegal repetition</code>. Please help me to overcome this issue .</p>
  
  <p>My code </p>
  
  <pre><code>Pattern pattern                     = Pattern.compile("\\{\\{(.*?)\\}\\}");
  Matcher matcher                     = pattern.matcher(text);
   while(matcher.find()){
              matches.add(matcher.group());
          }
  
  for (String match : matches) 
  {
      match = match.substring(2 , match.length()-2); // I WANT TO GET ONLY SOME | VALUE FROM THE PATTERN
      String splitArray[] = match.split("\\|");
      String value1 = splitArray[0].trim();
      String value2 = splitArray[1].trim();
      text = text.replaceAll(match , value1);
  }
  </code></pre>