قاسم بساکی
نویسنده:
قاسم بساکی
تاریخ:
9 ماه پیش
بازدید : 616

استفاده از هوش مصنوعی برای اعتبار سنجی کاراکتر های ورودی

رجکس اعتبار سنجی

همیشه توی اعتبار سنجی مقادیر ورودی یه چالش هست که اجازه ورود کاراکتر های غیر مجاز وجود نداشه باشه

یه ابزار هوش مصنوعی وجود داره که قراره ازش بپرسیم چطوری فقط به کاراکتر های مجاز اجازه ورود بدیم؟

 

------------------------------------------------------------

در زبان سی شارپ

آدرس وبسایت ZZZCode :

https://zzzcode.ai/code-generator?id=6be6b88a-38a4-465f-8e15-cd7b4157967a

هدف:

در زبان سی شارپ با استفاده از Regex چطور مانع ورود اطلاعات غیر مجاز شویم. در حالی که همه حروف فارسی و انگلیسی و اعداد و کاراکترهای مجاز دریافت شود

سوال:

How can I get a regex that allows to input all Latin (lowercase and uppercase) and Arabic characters and numbers and legal characters in C#

نتیجه:

string regexPattern = @"^[\p{L}\p{N}\p{P}\p{Zs}]+$";

This regex pattern allows you to input all Latin (lowercase and uppercase), Arabic characters, numbers, and legal characters. It uses Unicode character properties to match the desired characters.

Explanation:

  • ^ asserts the start of the string.
  • [\p{L}\p{N}\p{P}\p{Zs}] matches any character that falls into one of the following Unicode categories:
    • \p{L} matches any kind of letter from any language.
    • \p{N} matches any kind of numeric character.
    • \p{P} matches any kind of punctuation character.
    • \p{Zs} matches any kind of space separator.
  • + quantifier ensures that one or more characters are matched.
  • $ asserts the end of the string.

Please note that this regex pattern may need to be modified based on your specific requirements.

------------------------------------------------------------

در زبان PHP

آدرس وبسایت ZZZCode :

https://zzzcode.ai/code-generator?id=1325282e-a02e-4e12-bf85-b68eb633f797

هدف:

در زبان PHP با استفاده از Regex چطور مانع ورود اطلاعات غیر مجاز شویم. در حالی که همه حروف فارسی و انگلیسی و اعداد و کاراکترهای مجاز دریافت شود

سوال:

How can I get a regex that allows to input all Latin (lowercase and uppercase) and Arabic characters and numbers and legal characters in PHP

نتیجه:

$regexPattern = '/^[\p{L}\p{N}\p{Pd}\p{Pc}\p{Zs}]+$/u';

This regex pattern allows you to input all Latin (lowercase and uppercase), Arabic characters, numbers, and legal characters. The pattern uses Unicode properties to match the desired characters.

Please note that the /u modifier at the end of the pattern is used to enable Unicode matching.

Feel free to use this regex pattern in your PHP code to validate input that includes Latin, Arabic characters, numbers, and legal characters.

------------------------------------------------------------

در زبان جاوااسکریپت

آدرس وبسایت ZZZCode :

https://zzzcode.ai/code-generator?id=eb4967de-832e-4099-b306-6be8a4938cc2

هدف:

در زبان JavaScript با استفاده از Regex چطور مانع ورود اطلاعات غیر مجاز شویم. در حالی که همه حروف فارسی و انگلیسی و اعداد و کاراکترهای مجاز دریافت شود

سوال:

How can I get a regex that allows to input all Latin (lowercase and uppercase) and Arabic characters and numbers and legal characters in JS

نتیجه:

const regex = /^[a-zA-Z0-9\s@.#!$%^&*()+=\-[\]{}|\\:/?.,_\u0600-\u06FF]*$/u ;

This regular expression allows you to input all Latin (lowercase and uppercase), Arabic characters, numbers, and legal characters. It uses Unicode property escapes to match the specified character categories.

Please note that the /u flag at the end of the regular expression is important to enable full Unicode matching.

You can use this regular expression in JavaScript to validate user input or perform pattern matching operations.

------------------------------------------------------------