I am trying to remove everything from the string except the first 20 characters. But the regex removes the first 20 and saves the rest. How can i solve this?
Here is my code:
[% p.name | remove('(.{20})', '$1') %]
I also tried this:
[% p.name.replace('(.{20})', '$1')) %]
Your regular expression will not match a string whose length is less than 20.
Using:
[% p.name.replace('(?<=.{20}).*', '')) %]
Or:
[% p.name.replace('(.{0,20}).*', '$1')) %]
Source: https://habr.com/ru/post/1439135/More articles:How to configure GUI extension - tridionHow to pass branch name in MSBuild script in TeamCity? - msbuildIntercepting tips on delphi - delphiThe official / recommended / permissible maximum number of entries (or RAM table size) in the ETS / Mnesia RAM table - linuxSwipe with jQuery Mobile 1.2, PhoneGap 2.1 and Android 4.0.4 not working properly - androidTridion 2011 SP1 SDL code freezes when creating a Query Query object - tridionCharacter increment in string - c #MySQL: How many UPDATES per second can an average box support? - performanceKnpGaufette / Symfony2 / AmazonS3 - phpFabric.js - Shade Filter - javascriptAll Articles