From 419578b439481aaa9da6c10bc826d56ee001a9fd Mon Sep 17 00:00:00 2001 From: Ivan Izmailov Date: Sun, 3 Oct 2021 21:51:53 +0300 Subject: [PATCH] simplified regex --- src/innonymous/components/Register.jsx | 2 +- src/innonymous/components/menu/CreateRoomForm.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/innonymous/components/Register.jsx b/src/innonymous/components/Register.jsx index 2a20ddc..ad7fece 100644 --- a/src/innonymous/components/Register.jsx +++ b/src/innonymous/components/Register.jsx @@ -12,7 +12,7 @@ import {Cookies, withCookies} from 'react-cookie'; class Register extends React.Component { - static nameRegex = '^[A-Za-z0-9А-Яа-яЁё][A-Za-z0-9А-Яа-яЁё \\-_]{0,30}[A-Za-z0-9А-Яа-яЁё]$'; + static nameRegex = /^[\p{Letter}0-9][\p{Letter}0-9\-_\s]{0,30}[\p{Letter}0-9]$/u; static goodNameMessage = 'Great name :3'; static nameRestrictionsMessage = '2-32 characters (A-z, 0-9, _, -)'; static propTypes = {cookies: instanceOf(Cookies).isRequired}; diff --git a/src/innonymous/components/menu/CreateRoomForm.jsx b/src/innonymous/components/menu/CreateRoomForm.jsx index 24edf28..bc289a8 100644 --- a/src/innonymous/components/menu/CreateRoomForm.jsx +++ b/src/innonymous/components/menu/CreateRoomForm.jsx @@ -8,7 +8,7 @@ import Api from "../../Api"; class CreateRoomForm extends React.Component { - static nameRegex = '^[A-Za-z0-9А-Яа-яЁё][A-Za-z0-9А-Яа-яЁё \\-_]{3,30}[A-Za-z0-9А-Яа-яЁё]$'; + static nameRegex = /^[\p{Letter}0-9][\p{Letter}0-9\-_\s]{3,30}[\p{Letter}0-9]$/u; static goodNameMessage = 'Great name :3'; static nameRestrictionsMessage = '5-32 characters (A-z, 0-9, _, -)'; static propTypes = {cookies: instanceOf(Cookies).isRequired};