Regular Expression ASCII Converting. Regular Expression Regular Expression is a tool to check if a string matches some rules. It is a very complicated.

Slides:



Advertisements
Similar presentations
Session 3BBK P1 ModuleApril 2010 : [#] Regular Expressions.
Advertisements

Intro to Scala Lists. Scala Lists are always immutable. This means that a list in Scala, once created, will remain the same.
SYMBOL TABLES &CODE GENERATION FOR EXECUTABLES. SYMBOL TABLES Compilers that produce an executable (or the representation of an executable in object module.
BBK P1 Module2010/11 : [‹#›] Regular Expressions.
CSCI 6962: Server-side Design and Programming Input Validation and Error Handling.
Regular Expressions, Backus-Naur Form and Reverse Polish Notation.
Regular Expressions using Ruby Assignment: Midterm Class: CPSC5135U – Programming Languages Teacher: Dr. Woolbright Student: James Bowman.
Chapter 14 Perl-Compatible Regular Expressions Part 1.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Fundamentals of Strings and Characters Characters.
Chapter 9 Characters and Strings. Topics Character primitives Character Wrapper class More String Methods String Comparison String Buffer String Tokenizer.
25-Jun-15 JavaScript Language Fundamentals II. 2 Exception handling, I Exception handling in JavaScript is almost the same as in Java throw expression.
28-Jun-15 String and StringBuilder Part I: String.
Regular expression. Validation need a hard and very complex programming. Sometimes it looks easy but actually it is not. So there is a lot of time and.
Regular Expressions. String Matching The problem of finding a string that “looks kind of like …” is common  e.g. finding useful delimiters in a file,
Regular Expressions Dr. Ralph D. Westfall May, 2011.
Pattern matching with regular expressions A common file processing requirement is to match strings within the file to a standard form, e.g. address.
Faculty of Sciences and Social Sciences HOPE JavaScript Validation Regular Expression Stewart Blakeway FML
PHP Workshop ‹#› Data Manipulation & Regex. PHP Workshop ‹#› What..? Often in PHP we have to get data from files, or maybe through forms from a user.
PHP Using Strings 1. Replacing substrings (replace certain parts of a document template; ex with client’s name etc) mixed str_replace (mixed $needle,
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Characters In Java, single characters are represented.
Characters The data type char represents a single character in Java. –Character values are written as a symbol: ‘a’, ‘)’, ‘%’, ‘A’, etc. –A char value.
1 9/27/05CS360 Windows Programming Strings, Regex, Web Response.
ASP.NET Programming with C# and SQL Server First Edition Chapter 5 Manipulating Strings with C#
Strings The Basics. Strings can refer to a string variable as one variable or as many different components (characters) string values are delimited by.
CIS 451: Regular Expressions Dr. Ralph D. Westfall January, 2009.
Regular Expressions Regular expressions are a language for string patterns. RegEx is integral to many programming languages:  Perl  Python  Javascript.
Strings CS303E: Elements of Computers and Programming.
1 CSC 594 Topics in AI – Text Mining and Analytics Fall 2015/16 4. Document Search and Regular Expressions.
COP 4620 / 5625 Programming Language Translation / Compiler Writing Fall 2003 Lecture 3, 09/11/2003 Prof. Roy Levow.
Regular Expressions.
String Manipulation. Strings have their own properties and methods, just like a textbox or label or form does.
Built-in Data Structures in Python An Introduction.
C# Strings 1 C# Regular Expressions CNS 3260 C#.NET Software Development.
Regular Expressions for PHP Adding magic to your programming. Geoffrey Dunn
CSC 4630 Meeting 21 April 4, Return to Perl Where are we? What is confusing? What practice do you need?
GREP. Whats Grep? Grep is a popular unix program that supports a special programming language for doing regular expressions The grammar in use for software.
Introduction to Lex Ying-Hung Jiang
CSCI 3327 Visual Basic Chapter 12: Strings, Characters and Regular Expressions UTPA – Fall 2011.
Vladimir Misic: Characters and Strings1Tuesday, 9:39 AM Characters and Strings.
Perl Day 4. Fuzzy Matches We know about eq and ne, but they only match things exactly We know about eq and ne, but they only match things exactly –Sometimes.
Copyright © Curt Hill Regular Expressions Providing a Search Pattern.
1 Validating user input is the bane of every software developer’s existence. When you are developing cross-browser web applications (IE4+ and NS4+) this.
10 – Java Script (3) Informatics Department Parahyangan Catholic University.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
Arrays and Strings in Assembly
String class. Method concat Create string object –> String st1, st2; Input character to string object –> st1=br.readLine(); st2= br.readLine(); Use method.
Chapter 8 Characters and Strings. Objectives In this chapter, you will learn: –To be able to use the functions of the character handling library ( ctype).
17-Feb-16 String and StringBuilder Part I: String.
An Introduction to Regular Expressions Specifying a Pattern that a String must meet.
Regular expressions Day 11 LING Computational Linguistics Harry Howard Tulane University.
Variable Variables A variable variable has as its value the name of another variable without $ prefix E.g., if we have $addr, might have a statement $tmp.
-Joseph Beberman *Some slides are inspired by a PowerPoint presentation used by professor Seikyung Jung, which was derived from Charlie Wiseman.
Searching, Modifying, and Encoding Text. Parts: 1) Forming Regular Expressions 2) Encoding and Decoding.
Python Pattern Matching and Regular Expressions Peter Wad Sackett.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
LESSON 8: INTRODUCTION TO ARRAYS. Lesson 8: Introduction To Arrays Objectives: Write programs that handle collections of similar items. Declare array.
Lesson 4 String Manipulation. Lesson 4 In many applications you will need to do some kind of manipulation or parsing of strings, whether you are Attempting.
Regular Expressions, Backus-Naur Form and Reverse Polish Notation
Regular Expressions Upsorn Praphamontripong CS 1110
Regular Expressions 'RegEx'.
Perl-Compatible Regular Expressions Part 1
University of Central Florida COP 3330 Object Oriented Programming
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Pattern Matching in Strings
String and StringBuilder
String and StringBuilder
CS 1111 Introduction to Programming Fall 2018
String and StringBuilder
String methods 26-Apr-19.
Presentation transcript:

Regular Expression ASCII Converting

Regular Expression Regular Expression is a tool to check if a string matches some rules. It is a very complicated topic. We only give some basic rules here. Suppose that ~ means match. Then expression \d means a digital number. So "2" ~ \d "77023" not ~ \d If we want to match more digital numbers, we have "77023" ~ \d+ If we want to match exact 5 digital numbers, have "77023" ~ \d{5} Here {5} means repeating 5 times. expression \w means any letter of a-z or A-Z or 0-9 and _ expression \s means white space.

Regular Expression Definitions \dMatch a digital number or as [0-9] \wMatch any letter of a-z or A-Z or 0-9 and _ \sMatch a white space [abc]Match any one of a, b, c (abc)Match abc exact once (abc)+Match abc one or more times (abc)?Match abc zero or one times (abc)*Match abc zero or more times [^abc]Match any character except of a, b, c \W\S\DNot \w not \s and not \d [ ] means any one, ( ) means all of them $ #

More Definitions \bBoundary of a word \blet\b letter \.For period. (dot) \nNewline character.Any character except \n \\Match character slash \ ^Match the beginning of string (l in letter) \zMatch the end of string (y in many) $Match the end of string or end of a line |Or operator (g|s)et (get or set) {n}Exact n times {n, }At least n timed {n, m}At least n times and at most m times

Regular Expression (RE) examples The zip code three formations: So we first has expression \d{5} for Then we have either – or white space or none So it is [\s-]? The last 4 digits is optional, so is (\d{4})? or ([0-9]{4})? Thus we got \d{5}([\s-]\d{4})? The address like Its RE is

The telephone number could be: or (713) (713) RE of is \d{3}-\d{3}-\d{4} RE of (713) and (713) \(\d{3}\)\s?\d{3}-\d{4} So combine the together, we have ( \(\d{3}\)\s?|\d{3}-)\d{3}-\d{4}

Class Regex and Match Using System.Text.RegularExpressions; Class Regex object is used to search regular expression in the string. The constructor is Regex(string RE) the argument RE is the regular expression Basic operator is Match Match (string str) the argument str is the string to be searched the return value is Match object Match :: Success Success ==true means found match Match :: Index is the position of the match

Example Regex r = new Regex("\d[a-z]"); Match m = r.Match("123gabc456"); if (m.Success) { Response.Write("Found match at position " + m.Index); }

Replace operators for string string str = "Can you lend me your car?"; string str2 = str.Replace("you", "he"); Then str2 = "Can he lend me her car?"; However, if use regular expression replace string str3 = "he"); Then str3 = "Can he lend me your car?"; The regular expression string must

Char and byte converting Every byte is 8 bits, so its range is from 0 to 255. If the first bit is 0, the byte is used to express characters. Some character is not written- able, such as space. Convert a single Character is easy Char ch = 'A'; int n = (int)ch; Char c = (Char)99;

ASCII Table (0-63)

ASCII Table (64-127)

String and byte array Converting We can convert string to an byte array and vise versa. The converting object is ASCIIEncoding asciiConvertor = new ASCIIEncoding(); The name space is System.Text We need to use two major functions: byte [] GetBytes(string msg); and string GetString( byte[] data, int offset, int Length);

Data Structure object There are three major data structure objects (I) ArrayList the major operation is Add(…) and Remove() (ii) Stack the major operation is Push(…) and Pop() (iii) Queue the major operation is Enque(…) and Deque() Their name space is System.Collections. Note: They must add class objects. Any element read from those structure class object need cast to get the oringinal class data type.