#using <System.dll> #using <System.Windows.Forms.dll>

Size: px
Start display at page:

Download "#using <System.dll> #using <System.Windows.Forms.dll>"

Transcription

1 Lecture #8 Introduction.NET Framework Regular Expression A regular expression is a sequence of characters, each has a predefined symbolic meaning, to specify a pattern or a format of data. Social Security Numbers, for example, typically adapt a format of , where 9 means a digit from 0 to 9. An address, on the other hand, must have the format of: accountid@domainname.domaintype. Regular expressions provide an efficient method for validating inputs and processing texts. The extensive pattern-matching notation of regular expressions enables a programmer to parse a long string literal to find specific character patterns; to validate text to ensure that it matches a predefined pattern (such as an address); to extract, edit, replace, or delete text substrings; and to add the extracted strings to a collection in order to generate a report. Visit for a list of Regular Expression Language which defines the symbolic meaning of most escaped characters and wildcard characters that can be used to constitute a pattern of regular expression. The following is a sample list of them: \b: Matches a backspace (\u0008). \d: Matches any decimal digit. \D: Matches any character other than a decimal digit. \s: Matches any white-space (spaces, tabs, and newlines) character. \S: Matches any non-white-space character. \w: Matches any word character. A word character is an alphabet that are used to spell an English word. It does not include numerals and symbols. \W: Matches any non-word character; the opposite of \w. The following is the complete sample code that demonstrates how to use escaped character, \d, to match any single digit in the string. In the following case, 1 and 2 are the matched item. Interestingly, it is necessary to use the backslash character (\) in a regular expression indicates that the second backslash that follows it is the indicator of escaped sequence. Therefore, \\d can be recognized as \d. String^ pattern = "\\d"; String^ str = "There is 1 apple, 2 oranges."; MessageBox::Show(Regex::IsMatch(str, pattern) + ""); The Regex class represents the.net Framework s regular expression engine. It can be used to quickly parse large amounts of text to find specific character patterns; to extract, edit, replace, or delete text substrings; or to add the extracted strings to a collection to generate a report. The Regex::IsMatch() method is often used to validate string input. It returns true if there is a match. The.NET Framework provides the System.Text.RularExpressions.Regex class which is a regular expression engine which can process text using regular expressions language. Adding the following statement can eliminate the need to use fully qualified names. Visual C++ Programming Penn Wu, PhD 207

2 The following is another example with the pattern "\\S\\d\\w", which means The first must be a non-white-space character, the second must be a digit, and the third must be a word character. String^ pattern = "\\S\\d\\w"; String^ str = "M3z k6p 68h are 3 examples."; MessageBox::Show(Regex::IsMatch(str, pattern) + ""); A simple regular expression pattern, ^\\w+\\@\\w+\\.\\w3$, can validate an of the format accountname@domainname.domaintype. The following is a sample code. // Define a regular expression for address. String^ pattern = "^\\w+\\@\\w+\\.\\w3$"; String^ s = InputBox::Show("Enter an address:"); while (!Regex::IsMatch(s, pattern)) MessageBox::Show(s + " is a not valid address."); s = InputBox::Show("Enter an address:"); MessageBox::Show("Your address is " + s); Patterns also uses quantifiers and anchors. A quantifier specifies how many instances of the previous element (which can be a character, a group, or a character class) must be present in the input string for a match to occur. Commonly used quantifiers are: *: Matches the previous element zero or more times. +: Matches the previous element one or more times.?: Matches the previous element zero or one time. n: Matches the previous element exactly n times. Anchors, or atomic zero-width assertions, cause a match to succeed or fail depending on the current position in the string, but they do not cause the engine to advance through the string or consume characters. Frequently used anchors are: Visual C++ Programming Penn Wu, PhD 208

3 ^: The match must start at the beginning of the string or line. $: The match must occur at the end of the string or before \n at the end of the line or string. \A: The match must occur at the start of the string. \Z: The match must occur at the end of the string or before \n at the end of the string. \z: The match must occur at the end of the string. \G: The match must occur at the point where the previous match ended. A U.S. phone number, for example, in the format of can be validated by the following regular expression. ^\d3-\d3-\d4$ The following is a sample code that demonstrates how to validate a user input with the above regular expression. Regex^ rx = gcnew Regex("^\\d3-\\d3-\\d4$"); String^ s = InputBox::Show("Enter a phone number: "); if (rx->ismatch(s)) MessageBox::Show(s + " is a valid U.S. phone number format."); else MessageBox::Show(s + " is a not valid phone number format."); The following is a regular expression pattern ^\d3-\d2-\d4$ which can check if a string matches a valid social security number in the United States. This pattern is interpreted as shown in the following table. Pattern Description ^ Match the beginning of the input string. \d3 Match three decimal digits. - Match a hyphen. \d2 Match two decimal digits. - Match a hyphen. \d4 Match four decimal digits. $ Match the end of the input string. The following code demonstrates the use of this methods with the above pattern. Visual C++ Programming Penn Wu, PhD 209

4 // Define a regular expression for SSN. String^ pattern = "^\\d3-\\d2-\\d4$"; String^ s = InputBox::Show("Enter a SSN:"); while (!Regex::IsMatch(s, pattern)) MessageBox::Show(s + " is a not valid SSN."); s = InputBox::Show("Enter a SSN:"); MessageBox::Show("Your SSN is " + s); The alternation construct can matches any one element separated by the vertical bar ( ) character. For example, a pattern, th(e is at), can match the, this in this is the day. The following demonstrates how you can validate an URL address with three alternatives of protocols. // Define a regular expression for URL. String^ pattern = "(ftp http https)://(\\w+\\.)(\\w+\\.)\\w3"; String^ s = InputBox::Show("Enter a URL:"); while (!Regex::IsMatch(s, pattern)) MessageBox::Show(s + " is a not valid URL."); s = InputBox::Show("Enter a URL:"); MessageBox::Show("Your URL is " + s); The following syntax can define a character range which matches any single character in the range from first to last. [first - last] Some of the sample usages are: Regular expression ^[a-za-z]*$ Description must be alphabets only Visual C++ Programming Penn Wu, PhD 210

5 ^[0-9]*$ ^((0?[1-9] 1[012])[- /.](0?[1-9] [12][0-9] 3[01])[- /.](19 20)?[0-9]2)*$ ^((?:(?:25[0-5] 2[0-4][0-9] [01]?[0-9][0-9]?)\\.)3(?:25[0-5] 2[0-4][0-9] [01]?[0-9][0-9]?))*$ numerals only MM/DD/YYYY date format IPv4 address The following code can force the user to enter nothing but an integer as input. String^ s = InputBox::Show("Enter an integer:"); while (s==""!regex::ismatch(s, "^[0-9]*$")) MessageBox::Show("Must be a integer"); s = InputBox::Show("Enter an integer:"); int x = Convert::ToInt32(s); MessageBox::Show("Square is " + x*x); The following accepts only alphabets (upper- and lower-cases) as input. The * quantifier matches the previous element zero or more times. String^ s = InputBox::Show("Enter your first name:"); if (Regex::IsMatch(s, "^[a-za-z]*$")) MessageBox::Show("Welcome, " + s); else MessageBox::Show("A ridiculous name."); The following is a long regular expression pattern. ^[a-za-z0-9]\d2[a-za-z0-9](-\d3)2[a-za-z0-9]$ Visual C++ Programming Penn Wu, PhD 211

6 The following table shows how the regular expression pattern is interpreted. Pattern Description ^ Begin the match at the beginning of the line. [a-za-z0-9] Match a single alphabetic character (a through z or A through Z) or numeric character. \d2 Match two numeric characters. [a-za-z0-9] Match a single alphabetic character (a through z or A through Z) or numeric character. - Match a hyphen. \d3 Match exactly three numeric characters. (-\d3)2 Find a hyphen followed by three numeric characters, and match two occurrences of this pattern. [a-za-z0-9] Match a single alphabetic character (a through z or A through Z) or numeric character. $ End the match at the end of the line. The following example illustrates the use of the IsMatch(string) method to determine whether a string is a valid part number using the above regular expression pattern. The regular expression assumes that the part number has a specific format that consists of three sets of characters separated by hyphens. The first set, which contains four characters, must consist of an alphanumeric character followed by two numeric characters followed by an alphanumeric character. The second set, which consists of three characters, must be numeric. The third set, which consists of four characters, must have three numeric characters followed by an alphanumeric character. // Define a regular expression Regex^ rx = gcnew Regex("^[a-zA-Z0-9]\\d2[a-zA-Z0-9](- \\d3)2[a-za-z0-9]$"); // Define a test string. String^ s = InputBox::Show("Enter a part number:"); if (rx->ismatch(s)) MessageBox::Show(s + " is a valid part number."); else MessageBox::Show(s + " is a not valid part number."); This code also uses the Regex(pattern) constructor. This constructor can initialize a new instance of the Regex class for the specified regular expression. The syntax is: Regex^ objname = gcnew Regex(pattern); Visual C++ Programming Penn Wu, PhD 212

7 The pattern parameter consists of regular expression language elements that symbolically describe the string to match. The regular expression will be used to find case-sensitive matches of any alphabetical characters defined in pattern. For example, a pattern with the following format can match any single character enclosed by the brackets (by default, the match is case-sensitive). A character set is a series of characters. [characterset] In the following example, [ae] can match a or e in words like gray, bend, grand, glen, and lane. Interestingly, the letter A in An is capitalized. It does not match with the [ae] regular expression. Only the rest of words with either a or e or both in the sentence will match. The bold-faced are the ones that match with this regular expression. String^ str = "An apple a day keeps doctors away."; Regex^ regex1 = gcnew Regex("[ae]"); On the other hand, the escaped character \b means matches a backspace. The \w pattern matches any word character and the + pattern matches the previous element one or more times. Therefore, the pattern \b[at]\w+ actually means matches any word that begins with the letters a or t. In the following example, only the word the meet this requirement. String^ str = "Can you find the right word?"; Match^ match = Regex::Match(str, "\\b[at]\\w+"); A Regex object can be used only for defining the pattern. The checking of match is done by the MatchCollection class. The MatchCollection class represents the set of successful matches found by iteratively applying a regular expression pattern to the input string. The Count property of MatchCollection class returns the number of matches. The Item property returns an individual member of the collection. In addition to the IsMatch(string) method which indicates whether the regular expression specified in the Regex constructor finds a match in a specified input string, the Regex class also provides some useful methods. A later section of this lecture will discuss them in details. Match(string): Searches the specified input string for the first occurrence of the regular expression specified in the Regex constructor. Replace(string, string): In a specified input string, replaces all strings that match a regular expression pattern with a specified replacement string. Split(string): Splits an input string into an array of substrings at the positions defined by a regular expression pattern specified in the Regex constructor. Interestingly, an instance of the MatchCollection object is actually a System::Text::RegularExpressions::Match object, except it is populated as needed on a matchby-match basis. Therefore, the matched items are stored in a collection of Match class which can be access using a loop or the for..each statement. The following example illustrates the use of the MatchCollection class to check for matching items. The Regex->Matches() method searches the specified input string for all occurrences of a regular expression, yet it returns a MatchCollection object. Visual C++ Programming Penn Wu, PhD 213

8 String^ str = "An apple a day keeps doctors away."; Regex^ regex1 = gcnew Regex("\\b[at]\\w+"); MatchCollection^ m = regex1->matches(str); str = "There are " + m->count + " occurrences.\n"; for each (Match^ s in m) str += s + "\n"; MessageBox::Show(str); The output looks: The above example uses the MatchCollection class to create an instance that is actually an object of the Match class. However, you can simply create an instance of the Match class without using the MatchCollection class. The Match class provides a set of tools to process the results from a single regular expression match. An instance of the Match class is returned by the Regex::Match() method using the following syntax to return the first substring that matches a regular expression pattern in an input string. Match^ objid = Regex::Match(String, pattern) For example, the Regex::Match() method and represents the first pattern match in a string. Subsequent matches are represented by the Match::NextMatch() method. The Success property of a Match object is a Boolean property that can determine whether the regular expression pattern has been found in the string. If a match is found, the returned Match object s Value property contains the substring from input that matches the regular expression pattern. If no match is found, its value is set to be null (String.Empty). The Index property returns the position in the original string where the first character of the captured substring is found. The following is a complete sample code. String^ str = "Can you find the right 'tech' word?"; Match^ m = Regex::Match(str, "\\b[at]\\w+"); str += "\n"; while (m->success) Visual C++ Programming Penn Wu, PhD 214

9 str += "Found: " + m->value + " at position " + m->index + "\n"; m = m->nextmatch(); MessageBox::Show(str); The output looks: The regular expression pattern \b(\w+)\w+(\1)\b is interpreted as shown in the following table. Pattern Description \b Begin the match on a word boundary. (\w+) Match one or more word characters. This is the first capturing group. \W+ Match one or more non-word characters. (\1) Match the first captured string. This is the second capturing group. \b End the match on a word boundary. The following code uses the RegexMatch(string, string) method to find the first occurrence of a duplicated word in a string. It then calls the MatchNextMatch() method to find any additional occurrences. This sample code also examines the Match.Success property after each method call to determine whether the current match was successful and whether a call to the MatchNextMatch() method should follow. The Match->Groups property gets a collection of groups matched by the regular expression. A regular expression pattern can include subexpressions, which are defined by enclosing a portion of the regular expression pattern in parentheses. Every such sub-expression forms a group. A group is enclosed by a pair of parentheses. The regular expression pattern, \b(\w+)\w+(\1)\b, as stated earlier, has a boundary defined by a pair of \b and \b. The first group is defined by (\w+) and the second group is defined by (\1). The first group is represented by m->group[1] and the second is represented by m- >Group[2]. The Group[i]->Value property displays the result string for each capturing group. The Index property returns the position in the string where the first character of the captured substring is found. String^ pattern = "\\b(\\w+)\\w+(\\1)\\b"; String^ str = "This is a a farm that that raises dairy cattle."; Match^ m = Regex::Match(str, pattern); str = ""; // set value to blank Visual C++ Programming Penn Wu, PhD 215

10 The output looks: while (m->success) str += "Duplicate " + m->groups[1]->value; str += " found at position " + m->groups[2]->index + "\n"; m = m->nextmatch(); MessageBox::Show(str); The Match->Groups property is helpful in identify error(s) of a data format, for example, the regular expression pattern, (\d3)-(\d3)-(\d4), can match North American telephone numbers. It can be considered having three sub-expressions. The first consists of the area code, which composes the first three digits of the telephone number. This group is captured by the first portion of the regular expression, (\d3).the second consists of the individual telephone number, which composes the last seven digits of the telephone number. This group is captured by the second portion of the regular expression, (\d3), and the third group is represented by (\d4). These three groups can then be retrieved from the GroupCollection object that is returned by the Groups property, as the following example shows. Be sure to add an $ sign to end the match at the end of the line. String^ pattern = "(\\d3)-(\\d3)-(\\d4)$"; String^ input = InputBox::Show("Enter a phone number: "); MatchCollection^ m = Regex::Matches(input, pattern); String^ str = ""; for each (Match^ s in m) str += "Area Code: " + s->groups[1]->value + "\n"; str += "Prefix: " + s->groups[2]->value + "\n"; str += "Line No.: " + s->groups[3]->value + "\n"; MessageBox::Show(str); Visual C++ Programming Penn Wu, PhD 216

11 The output looks: Validating password according to a set of rules is a common practice of regular expression. String^ pattern = "^(?=.*\\d)(?=.*[a-z])(?=.*[a-z]).6,8$"; The above regular expression can validate a password with the following regulations: At least one digit At least one lowercase letter At least one uppercase letter the length must be 6 ~ 8 characters and Useful methods of the Regex class The Regex class supports several methods to process text-based on the result of matching of regular expression. The Regex::Replace(input, replacement), in a specified input string, can replace all strings that match a regular expression pattern with a specified replacement string. The search for matches starts at the beginning of the input string. The regular expression is the pattern defined by the constructor for the current Regex object. The following example defines a regular expression, \s+, that matches one or more white-space characters. The replacement string,, replaces them with a single space character. String^ input= "This is text with far too much whitespace."; String^ replacement = " "; Regex^ rx = gcnew Regex("\\s+"); // define the delimiter String^ result = rx->replace(input, replacement); MessageBox::Show(input + "\nbecomes\n" + result); The output looks: Visual C++ Programming Penn Wu, PhD 217

12 The following example uses a regular expression pattern (Mr\.? Mrs\.? Miss Ms\.? ) to match any occurrence of Mr, Mr., Mrs, Mrs., Miss, Ms or Ms.. The call to the Regex.Replace() method replaces the matched string with String.Empty; in other words, it removes it from the original string. String^ pattern = "(Dr\\.? Mr\\.? Mrs\\.? Miss Ms\\.? )"; array<string^>^ names = gcnew array <String^> "Miss Helen Chang", "Ms. Arcy Zolanski", "Dr. Steven Wang", "Mr. Thomas Brown", "Mrs. Nicole Smith", "Pastor Larry King"; String^ str = ""; for each (String^ name in names) str += (Regex::Replace(name, pattern, String::Empty)) + "\r"; MessageBox::Show(str); The Rege->Split(input, pattern) method splits an input string into an array of substrings at the positions defined by a regular expression pattern. The input string is split as many times as possible. If pattern is not found in the input string, the return value contains one element whose value is the original input string. The pattern parameter consists of regular expression language elements that symbolically describe the string to match. The following code shows how to split a string into a String array using a single semicolon as delimiter (:). String^ str = "Jane:Smith:Sales Rep.:46782:E321"; Regex^ rx = gcnew Regex(":"); // define the delimiter array<string^>^ s = rx->split(str); String^ result = ""; for each (String^ m in s) Visual C++ Programming Penn Wu, PhD 218

13 result += m + "\n"; MessageBox::Show(result); The output looks: The above code may be simplified to the following and still produce the same result. String^ str = "Jane:Smith:Sales Rep.:46782:E321"; array<string^>^ s = Regex::Split(str, ":"); // with pattern String^ result = ""; for each (String^ m in s) result += m + "\n"; MessageBox::Show(result); The following code uses two sets of capturing parentheses to extract the elements of a date, including the date delimiters, from a date string. The first set of capturing parentheses captures the hyphen, and the second set captures the forward slash. Interestingly, starting with the.net Framework 2.0, all captured text is also added to the returned array; therefore, it is necessary to use a continue statement to skip them. String^ input = "09/23/ "; String^ pattern = "(-) (/)"; String^ str = ""; Visual C++ Programming Penn Wu, PhD 219

14 for each (String^ s in Regex::Split(input, pattern)) if (s=="-" s=="/") continue; str += s + " "; MessageBox::Show(str); The output looks: Review Question 1. Which escaped character defined by the.net Framework matches any character other than a decimal digit? A. \B B. \b C. \d D. \D 2. Given the following code segment, which can identify any work with one character only? String^ pattern = "\\d"; String^ str = "That is a clock"; A. MessageBox::Show(IsMatch(str, pattern)); B. MessageBox::Show(IsMatch(str, pattern) + ""); C. MessageBox::Show(Regex::IsMatch(str, pattern) + ""); D. MessageBox::Show(Regex::IsMatch(str, pattern)); 3. Which can match three decimal digits? A. \d3 B. \d0-3 C. \d[3] D. \d[0-3] 4. Given a regular expression a pattern, th(e is at), which of the following cannot be matched? A. the B. theeth C. that D. this 5. The quantifier matches the previous element zero or more times. A. * B. ^ C.? D Which can match nothing but alphabets only? A. ^[a-z]*$ B. ^[a-za-z]*$ C. ^[A-z]*$ Visual C++ Programming Penn Wu, PhD 220

15 D. ^[a-za-z0-9]*$ 7. Which can define a regular expression with an instance named "rx" in Visual C++? A. Regex^ rx = Regex("^[a-zA-Z0-9]$"); B. Regex^ rx = "^[a-za-z0-9]$"; C. Regex^ rx = gcnew Regex("^[a-zA-Z0-9]$"); D. Regex^ rx = gcnew "^[a-za-z0-9]$"; 8. Given a regular expression, [ae], which word will not match with it? A. gray B. Apex C. teeth D. apple 9. Given the following code segment, which can represent the subsequent matches after the first match if any? String^ str = "Can you find the right 'tech' word?"; Match^ m = Regex::Match(str, "\\b[at]\\w+"); A. m = m->match(); B. m = m->nextmatch(); C. m = m->matchnext(); D. m = m->next(); 10. Given the following code segment, the output is. String^ str = "11:57:21 AM"; Regex^ rx = gcnew Regex(":"); array<string^>^ s = rx->split(str); String^ result = "The current time is: "; for each (String^ m in s) result += m + " "; A. The current time is: 11:57:21 AM B. The current time is: AM C. The current time is: AM D. The current time is: 11:57:21AM Visual C++ Programming Penn Wu, PhD 221

16 Lab #8.NET Framework Regular Expression Learning Activity #1: 1. Create the C:\cis223 directory if it does not exist. 2. Launch the Developer Command Prompt (not the regular Command Prompt) and change to the C:\cis223 directory. 3. Use Notepad to create a new text file named lab8_1.cpp with the following contents: using namespace System::IO::Ports; Regex^ rx = gcnew Regex("\\d3-\\d3-\\d4$"); String^ s = InputBox::Show("Enter a phone number [ ]: "); if (rx->ismatch(s)) SerialPort^ serialport1 = gcnew SerialPort; try // exception handling serialport1->open(); serialport1->dtrenable = true; serialport1->write("atdt " + s); catch (Exception^ e) MessageBox::Show(e->Message); else MessageBox::Show(s + " is a not valid phone number."); s = InputBox::Show("Enter a phone number: "); 4. Type cl /clr lab8_1.cpp /link /subsystem:windows /ENTRY:main and press [Enter] to compile. Test the program. A sample output looks: and or and Visual C++ Programming Penn Wu, PhD 222

17 5. Download the assignment template, and rename it to lab8.doc if necessary. Capture a screen shot similar to the above figure and paste it to the Word document named lab8.doc (or.docx). Learning Activity #2: validate URL 1. Use Notepad to create a new text file named lab8_2.cpp with the following contents: [STAThread] // Define a regular expression for URL. String^ pattern = "(ftp http https)://(\\w+\\.)(\\w+\\.)\\w3"; String^ s = InputBox::Show("Enter a URL:"); if (s=="") MessageBox::Show("Not input detected."); s = InputBox::Show("Enter a URL:"); while (!Regex::IsMatch(s, pattern)) MessageBox::Show(s + " is a not valid URL."); s = InputBox::Show("Enter a URL:"); //start the default Internet browser System::Diagnostics::Process::Start(s); 2. Compile and test the program. A sample output looks: 3. Capture a screen shot similar to the above figure and paste it to the Word document named lab8.doc (or.docx). Learning Activity #3: 1. Use Notepad to create a new text file named lab8_3.cpp with the following contents: and Visual C++ Programming Penn Wu, PhD 223

18 // Define a regular expression for repeated words. Regex^ rx = gcnew Regex("\\b(?<word>\\w+)\\s+(\\k<word>)\\b"); // Define a test string. String^ str = InputBox::Show("Enter a paragraph"); // Find matches. MatchCollection^ m = rx->matches(str); str = m->count + " matches found.\n\n"; for each (Match^ s in m) str += s->groups["word"]->value + " repeated at position " + s->index + "\n"; MessageBox::Show(str); 2. Compile and test the program. Type a sentence with repeating words. A sample output looks: Learning Activity #4: 1. Use Notepad to create a new text file named lab8_4.cpp with the following contents: and String^ pattern = "(\\d3)-(\\d3)-(\\d4)$"; String^ input = InputBox::Show("Enter a phone number: "); MatchCollection^ m = Regex::Matches(input, pattern); String^ str = ""; for each (Match^ s in m) str += "Area Code: " + s->groups[1]->value + "\n"; str += "Prefix: " + s->groups[2]->value + "\n"; str += "Line No.: " + s->groups[3]->value + "\n"; Visual C++ Programming Penn Wu, PhD 224

19 MessageBox::Show(str); 2. Compile and test the program. A sample output looks: 3. Capture a screen shot similar to the above figure and paste it to the Word document named lab8.doc (or.docx). Learning Activity #5: 1. Use Notepad to create a new text file named lab8_5.cpp with the following contents: and String^ processit(string^ str) Regex^ rx = gcnew Regex(":"); // define the delimiter array<string^>^ s = rx->split(str); String^ result = ""; for each (String^ m in s) result += m + "\t"; return result; array<string^>^ input = "Jane:Smith:Sales Rep.:46782:E321", "Tim:Locker:Tech II:45236:A421", "Helen:Chen:HR Staff:41689:M129", "Stanley:Wu:MIS:44217:K168" ; String^ output = "First\tLast\tDept\tExt.\tID\n";// \t is tab for (int i=0; i<input->length; i++) output += processit(input[i]) + "\n"; MessageBox::Show(output); 2. Compile and test the program. A sample output looks: Visual C++ Programming Penn Wu, PhD 225

20 3. Capture a screen shot similar to the above figure and paste it to the Word document named lab8.doc (or.docx). Submittal 1. Complete all the 5 learning activities and the programming exercise in this lab. 2. Create a.zip file named lab08.zip containing ONLY the following self-executable files. Lab8_1.exe Lab8_2.exe Lab8_3.exe Lab8_4.exe Lab8_5.exe lab8.doc (or.docx or.pdf) [You may be given zero point if this Word document is missing] 3. Upload the zipped file to Question 11 of Assignment as response. 4. Upload ex08.zip file to Question 12 as response. Note: You will not receive any credit if you submit file(s) to the wrong question. Programming Exercise 08: 1. Launch the Developer Command Prompt. 2. Use Notepad to create a new text file named ex08.cpp. 3. Add the following heading lines (Be sure to use replace [YourFullNameHere] with the correct one). //File Name: ex08.cpp //Programmer: [YourFullNameHere] 4. Write a Visual C++ code, with the InputBox.cpp library file, to ask the user to enter an IP address, then use an appropriate regular expression to validate the format of the IP address. Display Invalid IP format or Valid IP accordingly. and or and 5. Your application must meet the above requirements to get credit. No partial credit is given. 6. Download the programming exercise template, and rename it to ex08.doc if necessary. Capture Capture a screen similar to the above one and paste it to the Word document named ex08.doc (or.docx). 7. Compress the source file (ex08.cpp), executable code (ex08.exe), and Word document (ex08.doc) to a.zip file named ex08.zip. Grading criteria: Visual C++ Programming Penn Wu, PhD 226

21 You will earn credit only when the following requirements are fulfilled. No partial credit is given. You successfully submit both source file and executable file. Your source code must be fully functional and may not contain syntax errors in order to earn credit. Your executable file (program) must be executable to earn credit. Threaded Discussion Note: Students are required to participate in the thread discussion on a weekly basis. Student must post at least two messages as responses to the question every week. Each message must be posted on a different date. Grading is based on quality of the message. Question: Class, regular expression is design to handle structured data (data that has a format and type). Is it possible to use regular expression in a Visual C++ application to verify and valid the basic English structure, such as a incorrect sentence like "I is a boy, you is a girl, they is women."? [There is never a right-or-wrong answer for this question. Please free feel to express your opinion.] Be sure to use proper college level of writing. Do not use texting language. Visual C++ Programming Penn Wu, PhD 227

#using <System.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Windows::Forms;

#using <System.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Windows::Forms; Lecture #13 Introduction Exception Handling The C++ language provides built-in support for handling anomalous situations, known as exceptions, which may occur during the execution of your program. Exceptions

More information

Calling predefined. functions (methods) #using <System.dll> #using <System.dll> #using <System.Windows.Forms.dll>

Calling predefined. functions (methods) #using <System.dll> #using <System.dll> #using <System.Windows.Forms.dll> Lecture #5 Introduction Visual C++ Functions A C++ function is a collection of statements that is called and executed as a single unit in order to perform a task. Frequently, programmers organize statements

More information

Table 1: Typed vs. Generic Codes Scenario Typed Generic Analogy Cash Only Multiply Payment Options. Customers must pay cash. No cash, no deal.

Table 1: Typed vs. Generic Codes Scenario Typed Generic Analogy Cash Only Multiply Payment Options. Customers must pay cash. No cash, no deal. Lecture #15 Overview Generics in Visual C++ C++ and all its descendent languages, such as Visual C++, are typed languages. The term typed means that objects of a program must be declared with a data type,

More information

However, it is necessary to note that other non-visual-c++ compilers may use:

However, it is necessary to note that other non-visual-c++ compilers may use: Lecture #2 Anatomy of a C++ console program C++ Programming Basics Prior to the rise of GUI (graphical user interface) operating systems, such as Microsoft Windows, C++ was mainly used to create console

More information

Operating System x86 x64 ARM Windows XP Windows Server 2003 Windows Vista Windows Server 2008 Windows 7 Windows Server 2012 R2 Windows 8 Windows 10

Operating System x86 x64 ARM Windows XP Windows Server 2003 Windows Vista Windows Server 2008 Windows 7 Windows Server 2012 R2 Windows 8 Windows 10 Lecture #1 What is C++? What are Visual C++ and Visual Studio? Introducing Visual C++ C++ is a general-purpose programming language created in 1983 by Bjarne Stroustrup. C++ is an enhanced version of the

More information

Term Object-Oriented Paradigm Real-life example Abstraction Class declaration, creation, and definition

Term Object-Oriented Paradigm Real-life example Abstraction Class declaration, creation, and definition Lecture #6 What is a class and what is an object? Object-Oriented Programming Assuming that the instructor found a new breed of bear and decided to name it Kuma. In an email, the instructor described what

More information

Car. Sedan Truck Pickup SUV

Car. Sedan Truck Pickup SUV Lecture #7 Introduction Inheritance, Composition, and Polymorphism In terms of object-oriented programming, inheritance is the ability that enables new classes to use the properties and methods of existing

More information

Similarly, example of memory address of array and hash are: ARRAY(0x1a31d44) and HASH(0x80f6c6c) respectively.

Similarly, example of memory address of array and hash are: ARRAY(0x1a31d44) and HASH(0x80f6c6c) respectively. Lecture #9 What is reference? Perl Reference A Perl reference is a scalar value that holds the location of another value which could be scalar, arrays, hashes, or even a subroutine. In other words, a reference

More information

Automotive Multifaceted Result Analyzer

Automotive Multifaceted Result Analyzer Automotive Multifaceted Result Analyzer Mr. Rupesh Navnath Vitekar, Prof. Priya M. Shelke Department of Information Technology, Vishwakarma Institute of Information Technology, Savitribai Phule Pune University,

More information

#using <System.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Windows::Forms;

#using <System.dll> #using <System.Windows.Forms.dll> using namespace System; using namespace System::Windows::Forms; Lecture #12 Handling date and time values Handling Date and Time Values In the.net Framework environment, the DateTime value type represents dates and times with values ranging from 12:00:00 midnight,

More information

public class Animal // superclass { public void run() { MessageBox.Show("Animals can run!"); } }

public class Animal // superclass { public void run() { MessageBox.Show(Animals can run!); } } Lecture #8 What is inheritance? Inheritance and Polymorphism Inheritance is an important object-oriented concept. It allows you to build a hierarchy of related classes, and to reuse functionality defined

More information

IT 374 C# and Applications/ IT695 C# Data Structures

IT 374 C# and Applications/ IT695 C# Data Structures IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation

More information

Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book. Source Code

Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book. Source Code Contents Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Source Code Errata p2p.wrox.com xxi xxi xxii xxii xxiii xxiii xxiv

More information

accessmodifier [static] returntype functionname(parameters) { } private string getdatetime() { } public void getdatetime() { }

accessmodifier [static] returntype functionname(parameters) { } private string getdatetime() { } public void getdatetime() { } Lecture #6 User-defined functions User-Defined Functions and Delegates All C# programs must have a method called Main(), which is the starting point for the program. Programmers can also add other methods,

More information

1. After you have uploaded a file in the CE Import option, you will receive a notice asking if you want to open or save the results file.

1. After you have uploaded a file in the CE Import option, you will receive a notice asking if you want to open or save the results file. Correcting Invalid Data 1. After you have uploaded a file in the CE Import option, you will receive a notice asking if you want to open or save the results file. 2. Select Open so that you can save the

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

Data Source. Application. Memory

Data Source. Application. Memory Lecture #14 Introduction Connecting to Database The term OLE DB refers to a set of Component Object Model (COM) interfaces that provide applications with uniform access to data stored in diverse information

More information

Regular Expressions Explained

Regular Expressions Explained Found at: http://publish.ez.no/article/articleprint/11/ Regular Expressions Explained Author: Jan Borsodi Publishing date: 30.10.2000 18:02 This article will give you an introduction to the world of regular

More information

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments. Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started

More information

Advanced Handle Definition

Advanced Handle Definition Tutorial for Windows and Macintosh Advanced Handle Definition 2017 Gene Codes Corporation Gene Codes Corporation 525 Avis Drive, Ann Arbor, MI 48108 USA 1.800.497.4939 (USA) +1.734.769.7249 (elsewhere)

More information

Language Reference Manual

Language Reference Manual TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall

More information

using System; using System.Windows.Forms; public class Example { public static void Main() { if (5 > 3) { MessageBox.Show("Correct!

using System; using System.Windows.Forms; public class Example { public static void Main() { if (5 > 3) { MessageBox.Show(Correct! Lecture #4 Introduction The if statement C# Selection Statements A conditional statement (also known as selection statement) is used to decide whether to do something at a special point, or to decide between

More information

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA. DECLARATIONS Character Set, Keywords, Identifiers, Constants, Variables Character Set C uses the uppercase letters A to Z. C uses the lowercase letters a to z. C uses digits 0 to 9. C uses certain Special

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

Perl Programming. Bioinformatics Perl Programming

Perl Programming. Bioinformatics Perl Programming Bioinformatics Perl Programming Perl Programming Regular expressions A regular expression is a pattern to be matched against s string. This results in either a failure or success. You may wish to go beyond

More information

CSE 154 LECTURE 11: REGULAR EXPRESSIONS

CSE 154 LECTURE 11: REGULAR EXPRESSIONS CSE 154 LECTURE 11: REGULAR EXPRESSIONS What is form validation? validation: ensuring that form's values are correct some types of validation: preventing blank values (email address) ensuring the type

More information

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)

Regular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in

More information

Regular expressions. LING78100: Methods in Computational Linguistics I

Regular expressions. LING78100: Methods in Computational Linguistics I Regular expressions LING78100: Methods in Computational Linguistics I String methods Python strings have methods that allow us to determine whether a string: Contains another string; e.g., assert "and"

More information

2 nd Week Lecture Notes

2 nd Week Lecture Notes 2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous

More information

C++ Data Types and Variables

C++ Data Types and Variables Lecture #3 Introduction C++ Data Types and Variables Data is a collection of facts, such as values, messages, or measurements. It can be numbers, words, measurements, observations or even just descriptions

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

Searching Guide. September 16, Version 9.3

Searching Guide. September 16, Version 9.3 Searching Guide September 16, 2016 - Version 9.3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

More information

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All rights reserved. Java application A computer program that executes when you use the java command to launch the Java Virtual Machine

More information

Understanding Regular Expressions, Special Characters, and Patterns

Understanding Regular Expressions, Special Characters, and Patterns APPENDIXA Understanding Regular Expressions, Special Characters, and Patterns This appendix describes the regular expressions, special or wildcard characters, and patterns that can be used with filters

More information

Dr. Sarah Abraham University of Texas at Austin Computer Science Department. Regular Expressions. Elements of Graphics CS324e Spring 2017

Dr. Sarah Abraham University of Texas at Austin Computer Science Department. Regular Expressions. Elements of Graphics CS324e Spring 2017 Dr. Sarah Abraham University of Texas at Austin Computer Science Department Regular Expressions Elements of Graphics CS324e Spring 2017 What are Regular Expressions? Describe a set of strings based on

More information

Strings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Strings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics Strings Strings and their methods Produced by: Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Primitive Types: char Object Types: String Primitive vs Object Types

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Introduction to the C++ Programming Language

Introduction to the C++ Programming Language LESSON SET 2 Introduction to the C++ Programming Language OBJECTIVES FOR STUDENT Lesson 2A: 1. To learn the basic components of a C++ program 2. To gain a basic knowledge of how memory is used in programming

More information

Access Intermediate

Access Intermediate Access 2010 - Intermediate (103-134) Building Access Databases Notes Quick Links Building Databases Pages AC52 AC56 AC91 AC93 Building Access Tables Pages AC59 AC67 Field Types Pages AC54 AC56 AC267 AC270

More information

Regular Expressions. Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland

Regular Expressions. Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland Regular Expressions Michael Wrzaczek Dept of Biosciences, Plant Biology Viikki Plant Science Centre (ViPS) University of Helsinki, Finland November 11 th, 2015 Regular expressions provide a flexible way

More information

Homework 1 Due Tuesday, January 30, 2018 at 8pm

Homework 1 Due Tuesday, January 30, 2018 at 8pm CSECE 374 A Spring 2018 Homework 1 Due Tuesday, January 30, 2018 at 8pm Starting with this homework, groups of up to three people can submit joint solutions. Each problem should be submitted by exactly

More information

Computer Programming : C++

Computer Programming : C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

More information

Perl Regular Expressions. Perl Patterns. Character Class Shortcuts. Examples of Perl Patterns

Perl Regular Expressions. Perl Patterns. Character Class Shortcuts. Examples of Perl Patterns Perl Regular Expressions Unlike most programming languages, Perl has builtin support for matching strings using regular expressions called patterns, which are similar to the regular expressions used in

More information

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon Groups of up to three students may submit common solutions for each problem in this homework and in all future homeworks You are responsible

More information

Text. Text Actions. String Contains

Text. Text Actions. String Contains Text The Text Actions are intended to refine the texts acquired during other actions, for example, from web-elements, remove unnecessary blank spaces, check, if the text matches the defined content; and

More information

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d. Gaddis: Starting Out with Python, 2e - Test Bank Chapter Two MULTIPLE CHOICE 1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical

More information

Chapter 2 Basic Elements of C++

Chapter 2 Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion

More information

Lab 3: Call to Order CSCI 2101 Fall 2018

Lab 3: Call to Order CSCI 2101 Fall 2018 Due: Monday, October 15, 11:59 pm Collaboration Policy: Level 1 Group Policy: Pair-Optional Lab 3: Call to Order CSCI 2101 Fall 2018 This week s lab will explore sorting, lists, and basic data analysis.

More information

Introduction to C# Applications

Introduction to C# Applications 1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 07: Data Input and Output Readings: Chapter 4 Input /Output Operations A program needs

More information

Access Intermediate

Access Intermediate Access 2013 - Intermediate 103-134 Advanced Queries Quick Links Overview Pages AC124 AC125 Selecting Fields Pages AC125 AC128 AC129 AC131 AC238 Sorting Results Pages AC131 AC136 Specifying Criteria Pages

More information

Access Intermediate

Access Intermediate Access 2010 - Intermediate 103-134 Advanced Queries Quick Links Overview Pages AC116 AC117 Selecting Fields Pages AC118 AC119 AC122 Sorting Results Pages AC125 AC126 Specifying Criteria Pages AC132 AC134

More information

Introduction to Regular Expressions Version 1.3. Tom Sgouros

Introduction to Regular Expressions Version 1.3. Tom Sgouros Introduction to Regular Expressions Version 1.3 Tom Sgouros June 29, 2001 2 Contents 1 Beginning Regular Expresions 5 1.1 The Simple Version........................ 6 1.2 Difficult Characters........................

More information

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 2

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 2 Jim Lambers ENERGY 211 / CME 211 Autumn Quarter 2007-08 Programming Project 2 This project is due at 11:59pm on Friday, October 17. 1 Introduction In this project, you will implement functions in order

More information

C Language, Token, Keywords, Constant, variable

C Language, Token, Keywords, Constant, variable C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C

More information

Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub

Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub Lebanese University Faculty of Science Computer Science BS Degree Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub 2 Regular expressions

More information

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

4. Structure of a C++ program

4. Structure of a C++ program 4.1 Basic Structure 4. Structure of a C++ program The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which

More information

First Time User Setup

First Time User Setup First Time User Setup Follow the instructions below if this is your first time to log in to NMJC s Single Sign-On system, Quick Launch. You will need to know your Student ID, birth date, and the last 4

More information

Lab 3: Call to Order CSCI 2101 Fall 2017

Lab 3: Call to Order CSCI 2101 Fall 2017 Lab 3: Call to Order CSCI 2101 Fall 2017 Due: Part 1: Tuesday, Oct 3, 11:59 pm, Part 2: Wednesday, Oct 11, 11:59 pm Collaboration Policy: Level 1 Group Policy: Part 1: Individual, Part 2: Pair-Optional

More information

Programming with C++ as a Second Language

Programming with C++ as a Second Language Programming with C++ as a Second Language Week 2 Overview of C++ CSE/ICS 45C Patricia Lee, PhD Chapter 1 C++ Basics Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Introduction to

More information

Introduction to Java Applications

Introduction to Java Applications 2 Introduction to Java Applications OBJECTIVES In this chapter you will learn: To write simple Java applications. To use input and output statements. Java s primitive types. Basic memory concepts. To use

More information

SIS Modernization Faculty (Instructor) Portal Training Guide

SIS Modernization Faculty (Instructor) Portal Training Guide Faculty (Instructor) Portal Training Guide Created on August 2017 Table of Contents Introduction to the New Faculty Portal... 1 Logging into the Faculty Portal... 1 Navigating the Faculty Portal... 5 Using

More information

Full file at C How to Program, 6/e Multiple Choice Test Bank

Full file at   C How to Program, 6/e Multiple Choice Test Bank 2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)

More information

Last Time. Strings. Example. Strings. Example. We started talking about collections. Strings, Regex, Web Response

Last Time. Strings. Example. Strings. Example. We started talking about collections. Strings, Regex, Web Response Last Time We started talking about collections o Hash tables o ArrayLists Strings, Regex, Web Response 9/27/05 CS360 Windows Programming 1 9/27/05 CS360 Windows Programming 2 Let s look at the example

More information

Creating Accounts Using Batch Load

Creating Accounts Using Batch Load User Guide Creating Accounts Using Batch Load Document Purpose This document guides site administrators through the process of creating ACT WorkKeys online accounts for multiple examinees using a batch

More information

Creating Accounts and Test Registrations Using Batch Load

Creating Accounts and Test Registrations Using Batch Load Quick Start Guide Creating Accounts and Test Registrations Using Batch Load Document Purpose This document contains information used by site administrators to create ACT WorkKeys online accounts and test

More information

The following is a simple if statement. A later lecture will discuss if structures in details.

The following is a simple if statement. A later lecture will discuss if structures in details. Lecture #2 Introduction What s in a C# source file? C# Programming Basics With the overview presented in the previous lecture, this lecture discusses the language core of C# to help students build a foundation

More information

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm CSECE 374 Fall 2016 Homework 1 Due Tuesday, September 6, 2016 at 8pm Starting with this homework, groups of up to three people can submit joint solutions. Each problem should be submitted by exactly one

More information

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It

More information

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming 1 Literal Constants Definition A literal or a literal constant is a value, such as a number, character or string, which may be assigned to a variable or a constant. It may also be used directly as a function

More information

Chapter 2: Introduction to C++

Chapter 2: Introduction to C++ Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++

More information

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

More information

fpp: Fortran preprocessor March 9, 2009

fpp: Fortran preprocessor March 9, 2009 fpp: Fortran preprocessor March 9, 2009 1 Name fpp the Fortran language preprocessor for the NAG Fortran compiler. 2 Usage fpp [option]... [input-file [output-file]] 3 Description fpp is the preprocessor

More information

JME Language Reference Manual

JME Language Reference Manual JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.

More information

Chapter 2 THE STRUCTURE OF C LANGUAGE

Chapter 2 THE STRUCTURE OF C LANGUAGE Lecture # 5 Chapter 2 THE STRUCTURE OF C LANGUAGE 1 Compiled by SIA CHEE KIONG DEPARTMENT OF MATERIAL AND DESIGN ENGINEERING FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING Contents Introduction to

More information

Regular Expressions. Regular expressions match input within a line Regular expressions are very different than shell meta-characters.

Regular Expressions. Regular expressions match input within a line Regular expressions are very different than shell meta-characters. ULI101 Week 09 Week Overview Regular expressions basics Literal matching.wildcard Delimiters Character classes * repetition symbol Grouping Anchoring Search Search and replace in vi Regular Expressions

More information

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) Crayon (.cry) Language Reference Manual Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) 1 Lexical Elements 1.1 Identifiers Identifiers are strings used

More information

Type Description Example

Type Description Example Lecture #1 Introducing Visual C# Introduction to the C# Language and the.net Framework According to Microsoft, C# (pronounced C sharp ) is a programming language that is designed for building a variety

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

More information

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have

More information

Paolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems

Paolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems aim to facilitate the solution of text manipulation problems are symbolic notations used to identify patterns in text; are supported by many command line tools; are supported by most programming languages;

More information

Sensitive Data Detection

Sensitive Data Detection The following topics explain sensitive data detection and how to configure it: Basics, page 1 Global Options, page 2 Individual Sensitive Data Type Options, page 3 System-Provided Sensitive Data Types,

More information

psed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...]

psed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...] NAME SYNOPSIS DESCRIPTION OPTIONS psed - a stream editor psed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...] s2p [-an] [-e script] [-f script-file] A stream editor reads the input

More information

Searching Guide. November 17, Version 9.5

Searching Guide. November 17, Version 9.5 Searching Guide November 17, 2017 - Version 9.5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

More information

Chapter 5 Retrieving Documents

Chapter 5 Retrieving Documents Chapter 5 Retrieving Documents Each time a document is added to ApplicationXtender Web Access, index information is added to identify the document. This index information is used for document retrieval.

More information

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

CMSC 201 Spring 2016 Lab 08 Strings and File I/O

CMSC 201 Spring 2016 Lab 08 Strings and File I/O CMSC 201 Spring 2016 Lab 08 Strings and File I/O Assignment: Lab 08 Strings and File I/O Due Date: During discussion, April 4 th through April 7 th Value: 10 points Part 1: File Input Using files as input

More information

Bulk Registration File Specifications

Bulk Registration File Specifications Bulk Registration File Specifications 2017-18 SCHOOL YEAR Summary of Changes Added new errors for Student ID and SSN Preparing Files for Upload (Option 1) Follow these tips and the field-level specifications

More information

This page covers the very basics of understanding, creating and using regular expressions ('regexes') in Perl.

This page covers the very basics of understanding, creating and using regular expressions ('regexes') in Perl. NAME DESCRIPTION perlrequick - Perl regular expressions quick start Perl version 5.16.2 documentation - perlrequick This page covers the very basics of understanding, creating and using regular expressions

More information

Typescript on LLVM Language Reference Manual

Typescript on LLVM Language Reference Manual Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String

More information

Cisco CRM Communications Connector for Cisco CallManager Express

Cisco CRM Communications Connector for Cisco CallManager Express Cisco CRM Communications Connector for Cisco CallManager Express Cisco CRM Communications Connector (Cisco CCC) integrates Microsoft Customer Relationship Management (CRM) with Cisco CallManager Express

More information

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators 1 Professor: Sana Odeh odeh@courant.nyu.edu Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators Review What s wrong with this line of code? print( He said Hello ) What s wrong with

More information

Type of Cobol Entries

Type of Cobol Entries Review of COBOL Coding Rules: Columns Use Explanation 1-6 sequence numbers or page and line numbers (optional) 7 Continuation, Comment, or starting a new page Previously used for sequencechecking when

More information

The C++ Language. Arizona State University 1

The C++ Language. Arizona State University 1 The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Getting started with C++ (Part 2)

Getting started with C++ (Part 2) Getting started with C++ (Part 2) CS427: Elements of Software Engineering Lecture 2.2 11am, 16 Jan 2012 CS427 Getting started with C++ (Part 2) 1/22 Outline 1 Recall from last week... 2 Recall: Output

More information

Chapter 2. Lexical Elements & Operators

Chapter 2. Lexical Elements & Operators Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information