Regular Expressions
Background
All computer languages have a vocabulary to allow the programmers to write code. When the code’s vocabulary follows a specific syntax, the computer has instructions to follow. When the code is interpreted by the computer, the instructions are executed. Accordingly, the program “runs.” However, the program may not run or properly execute as desired when its code’s syntax is improper.
Objects
Regular Expressions are objects in both JavaScript and VBScript. These are Objects of the scripts. Scripts are the sequence of codes that are written in a specific order. Objects in its broadest sense are what you recognize. Objects can be a letter, a paragraph, or a page you read. It can be an image you see or a sound you hear. Even lines can be objects. The tangibles of the Computer Object just go on and on. For the programmer the word, objects, has special meaning. Regular Expression objects organize a collection of code where methods and properties can be attached.
Methods
Methods are basic procedures that are routinely run by the computer. For example, methods prescribe writing to the screen, printer, desktop or to a specific file. Properties are modifiers. They are used to store the objects attributes which are characteristics of the specified object. The wide range of characteristics can include: its color, font style, length, height, case or any other specific pattern requested. Another example is the global property which is all the occurrences of certain letters or words.
Regular Expression Methods
Regular Expressions have 3 methods: compile, execute, and test. Parentheses are placed after these methods, for example exec(), to indicate it is a procedure ready to perform action. The function compile(), is used to compile, put together an expression when the script executes. The exec() method checks for a match and returns the match; otherwise, if there is no match, it will return the absence of a value called null. The test() method is a Boolean test. If the match is there, it evaluates to true.
Results
Through the use of a combination of methods and properties, computer routines are developed and executed to provide specific functionality. For example, such functionality may direct the computer to write and provide the time and date. Regular Expressions are the modules of code that determine patterns. Specifically, this program object recognizes the occurrences of letters, words, numbers and symbols. In addition to pattern matching, Regular Expressions can be used for search and replace functions on text. In general, Regular Expressions provide for a reliable sample of traits or other observable features.