Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial 【正则表达式】检测字符串只包含数字、字母、下划线、汉字

【正则表达式】检测字符串只包含数字、字母、下划线、汉字

Jun 23, 2016 pm 01:54 PM
Underline Include Detection regular expression Chinese character

RT
要验证一下用户名,只包含数字、字母、下划线、汉字,要求即使打乱顺序也能测出来


回复讨论(解决方案)

规则串:/^\w+$/u
适用于 utf-8 字符集,非 utf-8 的,转成 utf-8 的再使用

'/^[\x7f-\xffA-Za-z0-9_]+$/'

$s = '%';var_dump(preg_match('/^\w+$/u', $s)); //int(0)var_dump(preg_match('/^[\x7f-\xffA-Za-z0-9_]+$/', $s)); //int(1)
Copy after login

全角的标点不当做汉字



'/^[\x7f-\xffA-Za-z0-9_]+$/'

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to type underline on the keyboard? How to type only underline without typing? How to type underline on the keyboard? How to type only underline without typing? Feb 22, 2024 pm 07:46 PM

Adjust the input method to English and hold down the Shift key and the minus key. Applicable model of the tutorial: Lenovo AIO520C System: Windows 10 Professional Edition: Microsoft Office Word 2022 Analysis 1 First check the Chinese and English typing of the input method and adjust it to English. 2Then hold down the Shift key and the Minus key on your keyboard at the same time. 3 Check the interface to see the underlined words. Supplement: How to quickly enter underline in Word document 1. If you need to enter an underline in Word, select the space with the mouse, then select the underline type in the font menu to enter. Summary/Notes: Be sure to change the input method to English before proceeding, otherwise the underscore cannot be successfully entered.

Solution to i7-7700 unable to upgrade to Windows 11 Solution to i7-7700 unable to upgrade to Windows 11 Dec 26, 2023 pm 06:52 PM

The performance of i77700 is completely sufficient to run win11, but users find that their i77700 cannot be upgraded to win11. This is mainly due to restrictions imposed by Microsoft, so they can install it as long as they skip this restriction. i77700 cannot be upgraded to win11: 1. Because Microsoft limits the CPU version. 2. Only the eighth generation and above versions of Intel can directly upgrade to win11. 3. As the 7th generation, i77700 cannot meet the upgrade needs of win11. 4. However, i77700 is completely capable of using win11 smoothly in terms of performance. 5. So you can use the win11 direct installation system of this site. 6. After the download is complete, right-click the file and "load" it. 7. Double-click to run the "One-click

Why can't the blank underline in the wps document be printed? How should I underline it? Why can't the blank underline in the wps document be printed? How should I underline it? Mar 20, 2024 am 09:40 AM

When entering text in Word, sometimes some positions need to be underlined to explain or emphasize. So why can't the blank underline in the WPS document be printed? How should I underline? The editor will introduce it to you in detail below, let’s take a look. In WPS documents, you can underline the blank spaces, as shown in the figure. How to do it? Please read below for detailed operations. Take the document in the picture as an example to demonstrate how to underline the blank space. Place the cursor on the right side of the colon of "Name" in the picture, and press the space bar on the keyboard. In order to facilitate the demonstration, I have increased the font size, as shown below: 2. Then, after the cursor reaches the set position, click and hold without letting go, and move to Drag on the left to the side of the colon, as shown in the picture: 3. Then click the "underline" icon, as indicated by the arrow in the picture.

How to type underline in Excel How to type underline in Excel Mar 20, 2024 am 08:37 AM

With the progress of society, technology has also developed rapidly, and electronic equipment has become a standard configuration in today's office. There are various types of office software today. Excel is still a commonly used operation in office software. We sometimes set settings in tables. In order to highlight these contents, we will choose different color fonts or deepen the fonts, and sometimes underline them for emphasis. The fonts are easy to set, but not everyone knows how to add underlines. Editor Today I will teach my novice friends how to underline in excel. 1. Open Excel and type a few words, as shown in the picture below. 2. Select the text, right-click and select "Format Cells" option, as shown in the figure below. 3. Find “single underline” and

MIT's latest masterpiece: using GPT-3.5 to solve the problem of time series anomaly detection MIT's latest masterpiece: using GPT-3.5 to solve the problem of time series anomaly detection Jun 08, 2024 pm 06:09 PM

Today I would like to introduce to you an article published by MIT last week, using GPT-3.5-turbo to solve the problem of time series anomaly detection, and initially verifying the effectiveness of LLM in time series anomaly detection. There is no finetune in the whole process, and GPT-3.5-turbo is used directly for anomaly detection. The core of this article is how to convert time series into input that can be recognized by GPT-3.5-turbo, and how to design prompts or pipelines to let LLM solve the anomaly detection task. Let me introduce this work to you in detail. Image paper title: Largelanguagemodelscanbezero-shotanomalydete

PHP regular expression validation: number format detection PHP regular expression validation: number format detection Mar 21, 2024 am 09:45 AM

PHP regular expression verification: Number format detection When writing PHP programs, it is often necessary to verify the data entered by the user. One of the common verifications is to check whether the data conforms to the specified number format. In PHP, you can use regular expressions to achieve this kind of validation. This article will introduce how to use PHP regular expressions to verify number formats and provide specific code examples. First, let’s look at common number format validation requirements: Integers: only contain numbers 0-9, can start with a plus or minus sign, and do not contain decimal points. floating point

How to validate email address in Golang using regular expression? How to validate email address in Golang using regular expression? May 31, 2024 pm 01:04 PM

To validate email addresses in Golang using regular expressions, follow these steps: Use regexp.MustCompile to create a regular expression pattern that matches valid email address formats. Use the MatchString function to check whether a string matches a pattern. This pattern covers most valid email address formats, including: Local usernames can contain letters, numbers, and special characters: !.#$%&'*+/=?^_{|}~-`Domain names must contain at least One letter, followed by letters, numbers, or hyphens. The top-level domain (TLD) cannot be longer than 63 characters.

Improved detection algorithm: for target detection in high-resolution optical remote sensing images Improved detection algorithm: for target detection in high-resolution optical remote sensing images Jun 06, 2024 pm 12:33 PM

01 Outlook Summary Currently, it is difficult to achieve an appropriate balance between detection efficiency and detection results. We have developed an enhanced YOLOv5 algorithm for target detection in high-resolution optical remote sensing images, using multi-layer feature pyramids, multi-detection head strategies and hybrid attention modules to improve the effect of the target detection network in optical remote sensing images. According to the SIMD data set, the mAP of the new algorithm is 2.2% better than YOLOv5 and 8.48% better than YOLOX, achieving a better balance between detection results and speed. 02 Background & Motivation With the rapid development of remote sensing technology, high-resolution optical remote sensing images have been used to describe many objects on the earth’s surface, including aircraft, cars, buildings, etc. Object detection in the interpretation of remote sensing images

See all articles