Regular Expression |R

Regular Expressio

'\s' : To accept the single white space.

eg: To accept the space along with text need to use.

([a-z]+\s)+


var validate_pattern_azdotspace = "([a-z]+[\\.\\s]?)*[a-z]+";



if you are using this with Validate.js lib. consider of adding additional backslash with '\s' Eg: '\\s'.


Use Case: Alphanumeric with space and dot. The expression must contain an alphabet.


'(?=.*[a-z])([a-z0-9]+[\\.\\s]?)*[a-z0-9]+[\\s]?'

Different blocks in expression
  1. (?=.*[a-z])
  2. ([a-z0-9]+[\\.\\s]?)*
  3. [a-z0-9]+[\\s]?
Block 1


Note:

if regex is used in javascript, need to add an escape character 
eg : "\s" for single white space, it can be represented in javascript "\\s"
the text should not contain an only numbers, it can accept numbers in between

Comments

Popular posts from this blog

python-docx | docx | No module named 'exceptions'

Fixing TortoiseSVN icons overlay in Windows 10

MySQL 8 User creation and grant privileges