Regular Expressions: The Proper Care and Feeding Zain Naboulsi MSDN Developer Evangelist Microsoft.

Slides:



Advertisements
Similar presentations
Inside an XSLT Processor Michael Kay, ICL 19 May 2000.
Advertisements

What is a Database By: Cristian Dubon.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 9 Strings.
1 Strings and Text I/O. 2 Motivations Often you encounter the problems that involve string processing and file input and output. Suppose you need to write.
Tools for Text Review. Algorithms The heart of computer science Definition: A finite sequence of instructions with the properties that –Each instruction.
This material in not in your text (except as exercises) Sequence Comparisons –Problems in molecular biology involve finding the minimum number of edit.
XML Introduction What is XML –XML is the eXtensible Markup Language –Became a W3C Recommendation in 1998 –Tag-based syntax, like HTML –You get to make.
Modern Information Retrieval Chapter 4 Query Languages.
IS 1181 IS 118 Introduction to Development Tools Chapter 4 String Manipulation and Regular Expressions.
PowerPoint: Tables Computer Information Technology Section 5-11 Some text and examples used with permission from: Note: We are.
DATA, DATABASES, AND QUERIES Managing Data in Relational Databases CS1100Microsoft Access - Introduction1.
Course Textbook: Build Your Own ASP.Net Website: Chapter 2
DATA, DATABASES, AND QUERIES Managing Data in Relational Databases CS1100Microsoft Access - Introduction1 Created By Martin Schedlbauer
PRX Functions: There is Hardly Anything Regular About Them! Ken Borowiak.
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,
Chapter 8: String Manipulation
Being an Organized Bulldog!. Welcome to Bogle! You will go to 5 different classes in one day: math, language arts, science, social studies, and an elective.
Create a Website on the CWU network Find “How to Post a Web Page with a PC”
Advanced File Processing
Text Parsing in Python - Gayatri Nittala - Gayatri Nittala - Madhubala Vasireddy - Madhubala Vasireddy.
Tutorial 14 Working with Forms and Regular Expressions.
Lecture 7: Perl pattern handling features. Pattern Matching Recall =~ is the pattern matching operator A first simple match example print “An methionine.
 Text Manipulation and Data Collection. General Programming Practice Find a string within a text Find a string ‘man’ from a ‘A successful man’
Regular Expressions in.NET Ashraya R. Mathur CS NET Security.
Computer Programming for Biologists Class 5 Nov 20 st, 2014 Karsten Hokamp
Web Application and Development Digital Media Department Unit Credit Value : 4 Essential Learning time : 120 hours Digital Media.
Introduction to Microsoft Access 2003 Mr. A. Craig Dixon CIS 100: Introduction to Computers Spring 2006.
ASP.NET Programming with C# and SQL Server First Edition Chapter 5 Manipulating Strings with C#
Programming Languages Meeting 13 December 2/3, 2014.
Regular Expressions Regular expressions are a language for string patterns. RegEx is integral to many programming languages:  Perl  Python  Javascript.
Perl and Regular Expressions Regular Expressions are available as part of the programming languages Java, JScript, Visual Basic and VBScript, JavaScript,
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Chapter 17 Creating a Database.
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
Post-Module JavaScript BTM 395: Internet Programming.
BY Sandeep Kumar Gampa.. What is Regular Expression? Regex in.NET Regex Language Elements Examples Regular Expression API How to Test regex in.NET Conclusion.
Review Please hand in your practicals and homework Regular Expressions with grep.
Regular Expressions Theory and Practice Jeff Schoolcraft MDCFUG 12/13/2005.
Overview A regular expression defines a search pattern for strings. Regular expressions can be used to search, edit and manipulate text. The pattern defined.
Working with Forms and Regular Expressions Validating a Web Form with JavaScript.
Module 6 – Generics Module 7 – Regular Expressions.
Satisfy Your Technical Curiosity Regular Expressions Roy Osherove Methodology & Team System Expert Sela Group The.
12. Regular Expressions. 2 Motto: I don't play accurately-any one can play accurately- but I play with wonderful expression. As far as the piano is concerned,
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.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
R EGULAR E XPRESSION IN P ERL (P ART 1) Thach Nguyen.
XP New Perspectives on XML, 2 nd Edition Tutorial 7 1 TUTORIAL 7 CREATING A COMPUTATIONAL STYLESHEET.
Unit 11 –Reglar Expressions Instructor: Brent Presley.
7 Copyright © 2009, Oracle. All rights reserved. Regular Expression Support.
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
#N14 Pattern Value (aka Substring attribute) SDD 1.1 Initial Discussion XXX = [Proposal | Initial Discussion | General Direction Proposal]
XML CORE CSC1310 Fall XML DOCUMENT XML document XML document is a convenient way for parsers to archive data. In other words, it is a way to describe.
1 Working with MS SQL Server Beginning ASP.NET in C# and VB Chapter 12.
Regular Expressions. What is it 4? Text searching & replacing Sequence searching (input, DNA) Sequence Tracking Machine Operation logic machines that.
Let’s Set up the Cornell Notes: Here we go: Here we go.
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
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 In Javascript cosc What Do They Do? Does pattern matching on text We use the term “string” to indicate the text that the regular.
Validation Controls Assist your users with providing the correct type of input for your application Assist your users with providing the correct type of.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/9/2006 Lecture 6 – String Processing.
Creative Create Lists Elizabeth B. Thomsen Member Services Manager
Product Training Program
Invitation to Computer Science, C++ Version, Fourth Edition
Regular Expressions 'RegEx'.
The Binary Number System
Error Handling and Validation
Unit# 8: Introduction to Computer Programming
Lesson 09: Lists Topic: Introduction to Programming, Zybook Ch 8, P4E Ch 8. Slides on website.
Smart Integration Express
Introduction to Computer Science
Presentation transcript:

Regular Expressions: The Proper Care and Feeding Zain Naboulsi MSDN Developer Evangelist Microsoft

Introduction to Regular Expressions What Are Regular Expressions? Why Would I Want To Use Them? Common Misconceptions Anatomy of An Regular Expression

Disclaimer All opinions in this session are provided "AS IS" with no warranties, and confer no rights. All opinions are my mine and don't necessarily reflect the opinion of Microsoft. All opinions are my mine and don't necessarily reflect the opinion of Microsoft.

What Are Regular Expressions?

Regular Expressions “Regular expressions provide a powerful, flexible, and efficient method for processing text. [They allow] you 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 in order to generate a report.”

Do What? Simply put, regular expressions will help you find text patterns and do pretty much whatever you want to it. It sounds simple but regular expressions are one of the most difficult and least understood constructs in programming.

Warning Regular expressions are part art and part science. There is a steep learning curve but the rewards are significant.

The Possibilities

Okay, So What Is A Pattern? “a regular or repetitive form, order, or arrangement”

PATTERNS ARE EVERYWHERE

Checker Board

Fibonacci Sequence

Text The IP Address for the server is but it should be , and I am not sure how we managed to get into the subnet but we need to remove ourselves from it immediately unless we are moving to it then I want the new IP to be I suppose.

YOU HAVE USED PATTERNS BEFORE

Wildcard Searches For Files Wildcards = VERY simple pattern matching constructs and are NOT regular expressions Examples:*.txtb*b*?un.txt

Why Use Regular Expressions?

Major Uses of Regular Expressions Matching = find any text anywhere regardless of complexity Substitution = once found, you can replace text

Features Can literally turn 10 lines of code into 1 Extremely efficient pattern matching mechanism Once learned, becomes one of the most indispensible techniques you can have

Languages That Support Regular Expressions All.NET languages JScript XML: XPath & XQuery T-SQLPERLJava [insert language here]

ASP.NET Control

Common Misconceptions

Misconceptions Regular Expressions can do complex programming logic Regular Expressions can do math Regular Expressions will give me winning lottery numbers

Anatomy of an Regular Expression

A Sample Expression

Anatomy CharactersMetacharactersSubexpressions

Characters A literal character represents any valid value represented by the current encoding method. For example the literal character is represented as the decimal value 65 in the ASCII encoding system.

Metacharacters Unlike literal characters, metacharacters are used as “place holders” for characters. For example, the metacharacter “\t” in regular expressions represents the tab character, whereas the “\d” matches any digit 0 through 9.

Subexpressions These are simply smaller expressions nested inside larger ones. For example, the following expression has a subexpression inside it: (john|jane)doe

Must Have Resources

Tools

Book

Tools

Summary

Summary Regular expressions can be used to manipulate and change text While there is a steep learning curve, regular expressions are invaluable as a programming tool Regular expressions are supported by virtually all major programming languages

Next Steps Check out some of the patterns on the RegExLib site Do a live search on regular expressions and see what others have to say about them Prepare your self mentally for a rewarding journey into the world of regular expressions Have Fun!!!