21
loading...
This website collects cookies to deliver better user experience
no worries, it's neither a food article nor I'm a food expert
// forward-slash:
in the javascript, we can write regex Pratten Through forward-slash also constructor function, it's calling literal /ab+c/
another it's calling constructor new RegExp('ab+c')
.0+
0 is our expected value and +
it's calling Quantifiers, The plus sign indicates one or more occurrences of the preceding 0
element.g flag modifier
it means g
is a modifier global flag match()
method will return only the first match in the string. match()
method searches a string for a match against a regex, and returns the matches, as an Array object, returns null if no match is found.[000]
from zero
and one
[1111]
match()
method returns null if no match is found. that's why we used after ||
or operator it helps to convert the null to the empty array []
after parentheses to grouping the expression we used join()
method it helps to convert to the string likes this '0000'
and '1111'
return
it just returns boolean value because we subtracted with zero and one length inside of math.abs function and meth.abs function return absolute value after that we compared less than or equal 1 or not this’s our solution with regex.decoded
after InstallShield with regex method re.findall()
.findall(pattern, string, flags=0)
method has up to three arguments.findall()
is probably the single most powerful function in the re module. findall()
finds *all* the matches and returns them as a list of strings, with each string representing one match.[a-zA-Z1-9]
a-z
it means given the ipute a to z any alphabetic smil latter and as same as that A-Z
any alphabetic capital letter also 1-9
it means 1 to 9 any number to the match. if we can use flag I
we don't need to mention capital and smail latter.['John', 'Doe', '123']
from decoded as a list now we can easily use with dictionary and we did that.