/    Sign up×
Community /Pin to ProfileBookmark

How to apply the regular expression for the given code

Hi,
i did the code for validating the string it working fine but i need to modify that code using regular expression. if u know plz modify and reply me

  • 1.

    isNotSpecialChar(string)
    It is a validate function to check the given string is not a Special Char.Here we can also given a additional parameter.These parameter value treated as not a special char.
    for example
    pm1 = ‘[email protected]‘ //– (Validation String) this is

    manditory value ;
    pm2 = ‘_’ //– (Exceptional Value) this is

    optional value;
    pm3 = ‘@’ //– (Exceptional Value) this is
    optional value;
    pm4 = ‘.’ //– (Exceptional Value) this is
    optional value;
    .
    .
    .
    isNotSpecialChar(pm1,pm2,pm3,pm4,….)

  • 2.

    isNotExceptionalChar(string)
    It is a validate function to check the string is not a Normal Char and not a Number and not a Special char

  • for example
    isNotExceptionalChar(‘`ds9A§’) //Output : return false

    code
    ====

    <script language=”JavaScript”>
    function isNotSpecialChar(string)
    {
    var ichars = “~!@#$%^&*()_+|`-=\[]{};’:”,./<>?”;
    if(arguments.length>1)
    for(var i = 1;i < arguments.length;i++)
    {
    ichars = ichars.replace(arguments[i],”);
    }
    for (var i = 0; i < string.length; i++) {
    if (ichars.indexOf(string.charAt(i)) != -1)
    return false;
    }
    return true;
    }
    function isNotExceptionalChar(string)
    {
    var ichars = “~!@#$%^&*()_+|`
    -=[]{};’:”,./<>?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
    “;
    for (var i = 0; i < string.length; i++)
    {
    if (ichars.indexOf(string.charAt(i)) == -1)
    return false;
    }
    return true;
    }
    isNotExceptionalChar(‘`ds9A§’) //return false
    isNotSpecialChar(‘[email protected]‘,’_
    ‘,’@’,’.’) //return true

    </script>

    By
    T.Varghese

    to post a comment
    JavaScript

    0Be the first to comment 😎

    ×

    Success!

    Help @tvarghese spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.28,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...