Re: Question-1: How to do a toNoCase

Discussion in 'HTML' started by Jonathan N. Little, Sep 10, 2013.

  1. Hot-Text wrote:
    > Need UpperCase and LowerCase for all Letters::
    > letters ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz0123456789
    >
    >
    > var input = form.input.value.toUpperCase();
    > var input = form.input.value.toLowerCase();
    >
    > Is it
    > ? CompareNoCase
    > or
    > ToDefaultCase Or
    > ???
    >


    No can grok? Would you mind trying using English when asking questions?

    Anyway this looks more like a JavaScript question where string objects
    have toUpperCase and toLowerCase methods, but I know of no CompareNoCase
    to ToDefaultCase methods for strings. Do you want to make a case
    insensitive comparison? If so then a RegExp object might be what you want.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Sep 10, 2013
    #1
    1. Advertising

  2. On Tue, 10 Sep 2013 10:10:57 -0400, Jonathan N. Little wrote:

    > Do you want to make a case
    > insensitive comparison? If so then a RegExp object might be what you
    > want.


    Given string values s1 and s2, for a string insensitive compare without
    changing s1 or s2, I think you can just use something like:

    if ( "James Bond 007".toLowerCase() == "jameS bonD 007".toLowerCase() ) {
    alert ( "Bond matches bonD" );
    }
    else {
    alert ( "bonD does not match Bond" );
    }

    --
    Denis McMahon,
    Denis McMahon, Sep 10, 2013
    #2
    1. Advertising

  3. 2013-09-10 21:07, Denis McMahon wrote:

    > On Tue, 10 Sep 2013 10:10:57 -0400, Jonathan N. Little wrote:
    >
    >> Do you want to make a case
    >> insensitive comparison? If so then a RegExp object might be what you
    >> want.

    >
    > Given string values s1 and s2, for a string insensitive compare without
    > changing s1 or s2, I think you can just use something like:
    >
    > if ( "James Bond 007".toLowerCase() == "jameS bonD 007".toLowerCase() ) {
    > alert ( "Bond matches bonD" );
    > }
    > else {
    > alert ( "bonD does not match Bond" );
    > }
    >


    Right. This is way better than regular expressions, because in regexps
    /i ignores case for Ascii letters only, so "Café" would not match
    "CAFÉ". Even though the OP seems to be thinking in Ascii terms only,
    there is no reason to build in such a restriction into code when you can
    easily avoid it.

    The toLowerCase() method is one of the few features of JavaScript have
    been reasonably well internationalized. It maps all uppercase letters to
    lowercase letters, in the writing systems that make case distinction, so
    it handles Greek and Russian en passant, and of course Latin letters
    like é, ô, þ. There are just a few points that you need to care about to
    be perfect here, mainly the issue of special casing rules for Turkish
    and Azeri, if they are relevant.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Sep 10, 2013
    #3
  4. Jonathan N. Little

    JJ Guest

    On Wed, 11 Sep 2013 06:19:55 -0600, Hot-Text wrote:
    > How do you make
    > /i
    > ignores Lower/UpperCase
    > for Ascii letters only?????????


    You mean ROMAN letters, right? A-Z?

    function romanUpperCase(str) {
    return str.replace(/[a-z]+/gi, function(str) {
    return str.toUpperCase();
    });
    }

    function romanLowerCase(str) {
    return str.replace(/[a-z]+/gi, function(str) {
    return str.toLowerCase();
    });
    }

    //example...

    var ref = "iNpUt 123 aBc ÃèÉôÖ xYz";
    var input = "InPuT 123 AbC ÃèÉôÖ XyZ";

    if (romanLowerCase(input) == romanLowerCase(ref)) {
    console.log("matched"); //always matched in this example
    } else {
    console.log("not matched");
    }

    //Those "ÃèÉôÖ" text won't be affected by
    //romanUpperCase or romanLowercase functions.
    //They only afect A-Z and a-z.
    JJ, Sep 11, 2013
    #4
  5. Jonathan N. Little

    BootNic Guest

    In article <l0nt1o$l4k$>,
    "Jukka K. Korpela" <> wrote:

    [snip]

    > Right. This is way better than regular expressions, because in
    > regexps /i ignores case for Ascii letters only, so "Café" would
    > not match "CAFÉ".


    [snip]

    var z = 'CAFÉ',
    a = z.match(/Café/i);
    document.write(a); /* CAFÉ */

    Should this be MAY ignore case for Ascii letters only and/or MAY not match?

    What UA or UA versions would not match?

    NOT to suggest that it is not a good ideal to change the string and patternto
    lower case to check for a match.

    [snip]



    --
    BootNic Thu Sep 12, 2013 11:49 am
    Humor is just another defense against the universe.
    *Mel Brooks*

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.11 (GNU/Linux)

    iEYEARECAAYFAlIx4okACgkQOcdbyBqMFBFRTQCfRchhS0clK7KMUZ2JKmB6ZtDK
    KrIAoNeFNJQ8bqFj8u5GdFspxDjhMR+m
    =ZXst
    -----END PGP SIGNATURE-----
    BootNic, Sep 12, 2013
    #5
  6. 2013-09-12 18:49, BootNic wrote:

    > In article <l0nt1o$l4k$>,
    > "Jukka K. Korpela" <> wrote:
    >
    > [snip]
    >
    >> Right. This is way better than regular expressions, because in
    >> regexps /i ignores case for Ascii letters only, so "Café" would
    >> not match "CAFÉ".

    >
    > [snip]
    >
    > var z = 'CAFÉ',
    > a = z.match(/Café/i);
    > document.write(a); /* CAFÉ */
    >
    > Should this be MAY ignore case for Ascii letters only and/or MAY not match?


    Oops. I stand corrected. I forgot how messy globalization issues in
    JavaScript regular expressions really are. The /i flag causes all
    letters (in the Unicode sense), with messy exceptions, to be converted
    to uppercase before the matching. So with messy exceptions, /i is
    Unicode-aware (whereas e.g. the \w construct has a strictly Ascii
    meaning for "word").

    > NOT to suggest that it is not a good ideal to change the string and pattern to
    > lower case to check for a match.


    Well, right. For example, 'Strauß'.match(/STRAUSS/i) yields null, since
    the letter ß is one of the nasty exceptions (not converted when
    performing /i match, since it expands to two characters in uppercasing),
    whereas 'Strauß'.toUpperCase() === 'STRAUSS' yields true.


    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Sep 12, 2013
    #6
  7. Jonathan N. Little

    BootNic Guest

    In article <>, "Hot-Text"
    <> wrote:

    > "BootNic" < in message
    > news:...


    > var input = form.input.value.toUpperCase();
    > var input = form.input.value.toLowerCase();


    > var input = form.input.value.toIgnoreCase();
    > var input = form.input.value.to?Case();


    > OutPut = to No Case at all to keep all Case the same be it Upper or
    > Lower


    Is the question how to set a variable to the value of a text input?

    <input type=text id=i0 value="Leave Case alOne">

    var myinput = document.getElementById('i0').value

    alert(myinput);




    --
    BootNic Thu Sep 12, 2013 07:29 pm
    The more you find out about the world, the more opportunities there are to
    laugh at it.
    *Bill Nye*

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.11 (GNU/Linux)

    iEYEARECAAYFAlIyTmYACgkQOcdbyBqMFBGXxQCcDHmU1r+FWGCb1TprZOlrmBwh
    pPQAn1PK34XD5X40Jmz0VRO3cMjiF9Xe
    =UVtc
    -----END PGP SIGNATURE-----
    BootNic, Sep 13, 2013
    #7
  8. Re: Question: How to do a toNoCase Answer-1:by BootNic

    Hot-Text wrote:
    > "BootNic" <> wrote in message news:...
    > Good Answer
    > For you are a 100% Right
    >


    Except it was not an answer but a *question* in which as usual you did
    not answer. Why not try posting in plain English in real sentences
    instead of your cryptic word jumble? So the question to you is, "what is
    it that you are trying to accomplish?" And example page would not hurt
    with a statement of what result you want and how your example fails.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Sep 14, 2013
    #8
  9. Re: Question: How to do a toNoCase Answer-1:by BootNic

    Hot-Text wrote:
    > "Jonathan N. Little" <> wrote in message news:l11kf7$52u$...



    >>Why not try posting in plain English in real sentences instead of your

    cryptic word jumble?


    > Take Care, Need's
    >
    > print(Uppercase(" QUESTION: THIS IS AN INDIVIDUAL LINE "));
    > print( Lowercase(" question this is an individual line "));
    > print('("Answer: NoCase")/r');
    >
    > Print(" In a IndiViduAl Line There Is No Get Rich Quick Case It Does Always Work" );
    > # # StateMent: Dou need not to shift key!
    >



    Rrrrrrrright.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Sep 15, 2013
    #9
  10. Re: Question: How to do a toNoCase Answer-1:by BootNic

    On 09/14/2013 03:02 PM, Hot-Text wrote:
    > "Jonathan N. Little" <> wrote in message news:l11kf7$52u$...
    >> Hot-Text wrote:
    >>> "BootNic" <> wrote in message news:...
    >>> Good Answer
    >>> For you are a 100% Right

    >> Except it was not an answer but a *question* in which as usual you did not answer. Why not try posting in plain English in real
    >> sentences instead of your cryptic word jumble? So the question to you is, "what is it that you are trying to accomplish?" And
    >> example page would not hurt with a statement of what result you want and how your example fails.

    >
    > Take Care, Need's
    >
    > print(Uppercase(" QUESTION: THIS IS AN INDIVIDUAL LINE "));
    > print( Lowercase(" question this is an individual line "));
    > print('("Answer: NoCase")/r');
    >
    > Print(" In a IndiViduAl Line There Is No Get Rich Quick Case It Does Always Work" );
    > # # StateMent: Dou need not to shift key!
    >
    >


    UpperCase = "ABC";
    LowerCase = "abc";
    NoCase = "";

    ;)

    --
    Norman
    Registered Linux user #461062
    AMD64X2 6400+ Ubuntu 10.04 64bit
    Norman Peelman, Sep 15, 2013
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    574
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    637
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    931
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    407
    Philip Meyer
    Nov 30, 2003
  5. Bit Byte
    Replies:
    1
    Views:
    820
    Teemu Keiski
    Jan 28, 2007
Loading...

Share This Page