1

While creating Item all types of special characters should be allowed. I tried to alter the regular expression in sitecore.config but unable to resolve it

<setting name="ItemNameValidation" value="^[\w\*\$][\w\s\-\$]*(\(\d{1,}\)){0,1}$"/>
2
  • 2
    I think you need to specify your question a bit more? All types of what? Chars? Commented Nov 2, 2017 at 10:46
  • 1
    I would warn against doing that. The item name makes up the Url - having any character in there is going to make for some horrible Urls. Why don't you just use the Display Name for special characters? That's what its there for, a nicely readable version of the item name.
    – Richard Seal
    Commented Nov 2, 2017 at 14:04

1 Answer 1

3

If you would like to allow all chars in items names in Sitecore you could use this patch:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>    
      <setting name="ItemNameValidation">
        <patch:attribute name="value">^.*$</patch:attribute>
      </setting>
   </settings>
  </sitecore>
</configuration>

Regex explanation:

^ asserts position at start of the string
.* matches any character (except for line terminators)
* Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy)
$ asserts position at the end of the string, or before the line terminator right at the end of the string (if any)
2
  • Getting an error as Parser Error Message: 'patch' is an undeclared prefix. Line 3061, position 6.
    – Ravindran
    Commented Nov 2, 2017 at 12:55
  • When using patch you will need to add the declaration to your "configuration" node: <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">. I have updated the answer with a complete config file. Commented Nov 2, 2017 at 13:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.