Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

3.4.2. Two Special Characters¶


import re
def checkvalid(string1):
    if re.search(r'[d.]s+[d.]', string1): return False # two numbers separated by spaces
    string1 = string1.replace(' ', '')
    return (bool(re.search(r'd', string1))               # must contain numbers
        and not re.search(r'.d*.', string1)            # a number can't contain two dots
        and not re.search(r'[$^]{2}|#[$^]|[$^]#[$^#]', string1) # obviously
        and not re.search(r'^[$^]|[$^]$', string1)        # special at the beginning or end
        and not re.search(r'^##|##$', string1)            # two hashes at the beginning or end
    )

Source by w3programmers.org #
 
PREVIOUS NEXT
Tagged: #Two #Special
ADD COMMENT
Topic
Name
2+5 =