Php can generate a random string that can contain numbers, letters, or a combination. Php can generate a random string to specify whether it is a pure number, a pure letter, or a mix. You can specify the length. Copy the code as follows: functionrand_zifu ($ what, $ number) {$ string php generates a random string
You can specify whether it is a pure number, a pure letter, or a combination.
You can specify
Php code for batch obtaining the first letter (Chinese characters, numbers, and English letters)
$ Mysql_server_name = '192. 0.0.1 '; // change it to your mysql database server.
$ Mysql_username = 'user'; // change the username of your mysql database.
$ Mysql_password = 'password'; // change the password of your mysql database.
$ Mysql_database = 'datab
This article mainly introduces how to generate a random string using php. you can specify pure numbers, pure letters, or a mix of php to generate a random string.
You can specify whether it is a pure number, a pure letter, or a combination.
You can specify the length.
The code is as follows:
Function rand_zifu ($ what, $ number ){
$ String = '';
For ($ I = 1; $ I // Hybrid
$ Panduan = 1;
If (
Import Java.util.scanner;public class Getnumdifchar {public static void main (string[] args) {Scanner scan = new Scanner (Sy stem.in); String str = scan.nextline (), int isletter = 0;int IsSpace = 0;int IsDigit = 0;int Isother = 0;for (int i = 0; i Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.Enter a line of characters to count the number of letters, spaces,
Console.Write ("You want to get the number of four-bit random verification code is:"); int a = Int. Parse (Console.ReadLine ()); Console.WriteLine ("Random Verification Code in turn:"); char[] arr = new char[] {' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' d ', ' e ', ' f ', ' g ', ' h ', ' I ', ' j ', ' l ', ' m ', ' n ', ' o ', ' P ', ' Q ', ' R ', ' s ', ' t ', ' u ', ' V ', ' w ', ' x ', ' y ', ' z '};
Rt
To verify the username, it contains only numbers, letters, underscores, kanji, and is required to be detected even if the order is scrambled.
Reply to discussion (solution)
Rule string:/^\w+$/uFor Utf-8 character set, non-utf-8, re-use of 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 (
Supports php verification code for Chinese letters, numbers, and custom fonts. For more information, see
The code is as follows:
/** Captcha Class base on php gd Lib* @ Author Design* @ Version 1.0* @ Demo* Include ('captchaclass. php ');* $ CaptchaDemo = new Captcha ();* $ CaptchaDemo-> createImage ();*/Class Captcha {// @ Define the image height of the verification codePrivate $ height;// @ Define th
Method One
The code is as follows
Copy Code
if (Preg_match ("/^d*$/", "4312")){echo "Full digit";}if (Preg_match ("/^[a-z]*$/i", "FDSFDFD")){echo "Full letter";}if (Preg_match ("/^[a-zd]*$/i", "fd4fd34")){echo "has numbers with letters.";}
Chinese characters
The code is as follows
Copy Code
$username =$_request[' username '];if (!preg_match
Website Login, user registration and so on need to use the verification code, here to record a simple 6-bit verification code generation method.The class used to generate the verification code:public class Randomnumsupplier{Private Const string Basecode = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";static random rannum = new Random ((int) DateTime.Now.Ticks);public static string Getvcode (int length){StringBuilder builder = new StringBuilder ();for (int i=0;i{int rnnum = Rannum.next (basecode. Length
/*** Auxiliary class * is used to record characters and locations **/class charpos {char C; int Pos; Public charpos (char C, int POS) {This. C = C; this. pos = Pos ;}}
/*** Convert the number into uppercase characters **/public class cnnummaker {private string integerpart; // The integer part is private string decimalpart; // Private stack for fractional parts
Output:
0-> 0 1-> 1 10-> 1 million-> 1 million-> 1 million 100-> 1 million 1000-> 1 million 10000-> 1 million 100000000 million-> 100000
I used a notebook, which is just happening. The keyboard input in my notebook is out of order, and all the letters are converted into numbers. I thought it was a computer problem at first, and I restarted it three times.
After studying for a while, I found that this is not a problem because I accidentally started the laptop keypad. If you do not dare to enjoy the solution exclusively, we will share the sol
In this example, characters other than Chinese characters, letters, and numbers are replaced with null.
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
///
///
Replacement character
///
///
///
Public
Static
String
Trimcharacter (
String
Asstring){
String
Sresult
=
""
;
Ask God to help write a regular expression that consists of only numbers, letters, Chinese, underscores,/, spaces. Urgent and urgent
Thighs to help me this rookie of the busy!! Thank you
------Solution--------------------
/^[\w \\]+$/u
Non-utf-8 need to be utf-8 before use
------Solution--------------------
^[\u4e00-\u9fa5_a-za-z0-9\s\\]+$
------Solution--------------------
$aa = ' I/1a_ '; Var_du
/*** Algorithmutil.java * com.tfedu.yuwen.util * Copyright (c) 2017, Beijing Poly-Wisdom Future Technology Co., Ltd. All rights reserved.*/ PackageCom.tfedu.yuwen.util;ImportJava.util.Random;/*** Algorithm Tool class * @authorKuangxiang ([email protected]) * @Date September 18, 2017*/ Public classAlgorithmutil {/*** Number of digits * */ Private Static Final intDIGIT = 8; /*** Verify number of code digits*/ Private Static Final intVerifycodedigit = 6; /*** * Generate ring ID * @returnstr
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.