ejabberd - Comments for "Only Latin JIDs REGEXP" https://www.ejabberd.im/node/5058 en Mike, thanks for help! https://www.ejabberd.im/node/5058#comment-58028 <p>Mike, thanks for help!</p> Sat, 12 Nov 2011 15:13:47 +0000 question77 comment 58028 at https://www.ejabberd.im Note that erlang treats "\" https://www.ejabberd.im/node/5058#comment-58024 <p>Note that erlang treats "\" as its own escaping character. So if you need to include the "\" into the regex pattern (say, if you need "-" inside square brackets), then you need to double-escape this in ejabberd.cfg:</p> <div class="codeblock"><code>{access, register}<br /> {acl, somechars, {user_regexp, &quot;^[0-9A-Za-z.\\-]+$&quot;}}.<br /> {access, register, [{allow, somechars}, {deny, all}]}. </code></div> <p>(I put the dot here unescaped, as it is not a metacharacter inside square brackets, but no harm if you will escape it, too)</p> <p>Also note that ejabberd.cfg is utf-8-encoded, and must not include the BOM. This is important if you use internationalized characters in it (like in your initial pattern "[а-яА-Я]"). If your editor includes BOM, or if it saves your file as ACSII, then ejabberd may not work properly. I use Cyrillic characters in my ejabberd.cfg (my users, to the contrary, almost exclusively use Cyrillic characters in their uids), and it works. Still, I don't know if this works with regex, because in utf-8, internationalized characters are multibyte, and this will work only if the string is internally converted to utf-16 and then passed to regex module, or if the regex module knows how to treat multibyte utf-8 sequences. This needs trial. Possibly you may need to use "\x{ABC}" to succeed in this case.</p> Fri, 11 Nov 2011 18:43:15 +0000 mikekaganski comment 58024 at https://www.ejabberd.im mikekaganski, thanks for https://www.ejabberd.im/node/5058#comment-58023 <p>mikekaganski, thanks for answer!</p> <p>Smth like this?</p> <p>In ejabberd.cfg:</p> <blockquote><p>{access, register}<br /> {acl, somechars, {user_regexp, "^[0-9A-Za-z\-]+$"}}.<br /> {access, register, [{allow, somechars}, {deny, all}]}. </p></blockquote> <p>Am I right?</p> Fri, 11 Nov 2011 15:00:22 +0000 question77 comment 58023 at https://www.ejabberd.im In those regexps on the page https://www.ejabberd.im/node/5058#comment-58022 <p>In those regexps on the page that you cite, you somehow forget that names usually consist of more than one character.<br /> I would suggest something like "^[\x20-\x7F]+$" or "^[0-9A-Za-z\-]+$" (note the plus :) )</p> Fri, 11 Nov 2011 12:56:02 +0000 mikekaganski comment 58022 at https://www.ejabberd.im