Results 1 to 6 of 6

Thread: JavaScript: RegExp and Boolean Object

  1. #1
    Join Date
    Nov 2009
    Posts
    67

    JavaScript: RegExp and Boolean Object

    I have recently began studying JavaScript. I have earlier never studied any programming language. Its only now that I am studying HTML and JavaScript from that last one month. And I have to confess that it is not easy for me at all. I want to know about the JavaScript objects: RegExp Object and Boolean Object. Can any one explain to me in detail about these objects with examples as well.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    J-Script: RegExp Object

    An abbreviation for Regular Expression is RegExp. This is useful for searching patterns in textboxes. You can specify the pattern you are searching for in the textbox. For this you have use RegExp IS this pattern. A single character is the simplest pattern. A more detailed pattern may consist of more than one characters and may also include checking for formats and substitutions. Using this you can also provide the characters to be searched from within a given string.

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Defining RegExp Object

    The keyword new is used for defining the Regular expression object- RegExp. It stores the search pattern specified. Here is how you define a RegExp object.
    var pat=new RegExp("n");
    The above code line will locate for the presence of letter n in RegExp object: pat. This object is used to find a given character or set of characters from the values in a textbox.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    RegExp methods- exec(), test() and compile().

    There are three methods which are contained in the J-Script RegExp Object. They are:
    • exec().
    • test().
    • compile().
    If you want to find a string pattern in a specified value and return it then you may use the exec() method which will give a null value if the string pattern is not found.
    If you want to just want to locate a string pattern from a given value than the test() method is useful. This method will provide false/true values.
    If you want to modify the RegExp you may use the compile() method of Regular Expression in J-Script.

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    Boolean Object of JavaScript

    JavaScript allows the conversion of a non-Boolean value to a Boolean value which is either false or true. Here is an example to create a Boolean value in JavaScript:
    var Jbool=new Boolean();
    Here is how to create a true boolean value object:
    var Jbool=new Boolean("Java");
    var Jbool=new Boolean(true);
    Here is how to create a false boolean value object:
    var Jbool=new Boolean(0);
    var Jbool=new Boolean(null);
    var Jbool=new Boolean("");

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    Re: JavaScript: RegExp and Boolean Object

    Example for compile() of RegExp:
    Code:
    var srh =new RegExp("w");
    document.write(srh.test("World is Beautiful"));
    srh.compile("t");
    document.write(srh.test("World is Beautiful"));
    Example for test() of RegExp:
    Code:
    var srh=new RegExp("f");
    document.write(srh.test("World is Beautiful forever"));
    JavaScript has a Regular Expressions to match the pattens in a text contained in a text box.

Similar Threads

  1. What is RegExp Modifiers in JavaScript?
    By Flaco in forum Software Development
    Replies: 4
    Last Post: 30-01-2010, 06:10 PM
  2. Date Object In Javascript
    By Level8 in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 12:07 PM
  3. JavaScript - The window object
    By Sheenas in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 11:38 AM
  4. History Object In JavaScript
    By ramsun in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 10:17 AM
  5. Location Object In JavaScript
    By technika in forum Software Development
    Replies: 5
    Last Post: 23-01-2010, 09:24 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,902,656.29188 seconds with 17 queries