les fonctions reguliere javascript
if(! pseudo.match(/^([a-zA-Z ]+)$/))
alert('Pseudo invalide');
les fonctions reguliere javascript
if(! pseudo.match(/^([a-zA-Z ]+)$/))
alert('Pseudo invalide');
javascript regex
//Declare Reg using slash
let reg = /abc/
//Declare using class, useful for buil a RegExp from a variable
reg = new RegExp('abc')
//Option you must know: i -> Not case sensitive, g -> match all the string
let str = 'Abc abc abc'
str.match(/abc/) //Array(1) ["abc"] match only the first and return
str.match(/abc/g) //Array(2) ["abc","abc"] match all
str.match(/abc/i) //Array(1) ["Abc"] not case sensitive
str.match(/abc/ig) //Array(3) ["Abc","abc","abc"]
//the equivalent with new RegExp is
str.match('abc', 'ig') //Array(3) ["Abc","abc","abc"]
javascript regex reference
// Javascript Regex Reference
// /abc/ A sequence of characters
// /[abc]/ Any character from a set of characters
// /[^abc]/ Any character not in a set of characters
// /[0-9]/ Any character in a range of characters
// /x+/ One or more occurrences of the pattern x
// /x+?/ One or more occurrences, nongreedy
// /x*/ Zero or more occurrences
// /x?/ Zero or one occurrence
// /x{2,4}/ Two to four occurrences
// /(abc)/ A group
// /a|b|c/ Any one of several patterns
// /\d/ Any digit character
// /\w/ An alphanumeric character (“word character”)
// /\s/ Any whitespace character
// /./ Any character except newlines
// /\b/ A word boundary
// /^/ Start of input
// /$/ End of input
javascript regex
// \d Any digit character
// \w An alphanumeric character (“word character”)
// \s Any whitespace character (space, tab, newline, and similar)
// \D A character that is not a digit
// \W A nonalphanumeric character
// \S A nonwhitespace character
// . Any character except for newline
// /abc/ A sequence of characters
// /[abc]/ Any character from a set of characters
// /[^abc]/ Any character not in a set of characters
// /[0-9]/ Any character in a range of characters
// /x+/ One or more occurrences of the pattern x
// /x+?/ One or more occurrences, nongreedy
// /x*/ Zero or more occurrences
// /x?/ Zero or one occurrence
// /x{2,4}/ Two to four occurrences
// /(abc)/ A group
// /a|b|c/ Any one of several patterns
// /\d/ Any digit character
// /\w/ An alphanumeric character (“word character”)
// /\s/ Any whitespace character
// /./ Any character except newlines
// /\b/ A word boundary
// /^/ Start of input
// /$/ End of input
js string to regex
const regex = new RegExp('https:\\/\\/\\w*\\.\\w*.*', 'g');
js regex
// get "bucket1337" from https://bucket1337.appspot.com.storage.googleapis.com/staging/blender_input/162480.glb"
//define string
let string = "https://bucket1337.appspot.com.storage.googleapis.com/staging/blender_input/162480.glb"
//define regexp
let bucketRegex = new RegExp(`(?<=https:\/\/).*(?=.app)`, 'gm')
// execute regexp
let result = string.match(bucketRegex)[0]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us