title: Thymeleaf - trying to use Java's replaceAll function in 'data-th-with'
body: <p>I have a div tag in my html page with a <code>data-th-with</code> attribute.  The old working code was this:</p>
  
  <pre><code>&lt;div class="facetSubMenu"
           data-th-with="searchMenuInput=${#strings.replace(searchMenu.getInputName(), '/', '-')}"
  </code></pre>
  
  <p>Now I learned I need to not only replace forward slashes but basically strip out any non-alphanumeric characters.  So I quickly learned that Thymeleaf's replace function does not handle regex.  So it looks like I will need to use Java's replaceAll function.</p>
  
  <p>So now I have this code:</p>
  
  <pre><code>&lt;div class="facetSubMenu"
           data-th-with="searchMenuInput=${searchMenu.getInputName().replaceAll('[^a-zA-Z0-9]', '')}"
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/TNftB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TNftB.png" alt="enter image description here"></a></p>
  
  <p>Picture added to show where the errors are occurring.  Hovering over each red error gives <code>Cannot resolve 'getInputName'</code> and <code>Cannot resolve 'replaceAll'</code> respectively.  Any ideas how I can use the replaceAll function correctly in this manner?</p>