Upcoming SlideShare
Loading in …5
×

# Regular expressions

240 views
178 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

No Downloads
Views
Total views
240
On SlideShare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Regular expressions

1. 1. Regular Expressions
2. 2. What are Regular Expressions?• They are a way of specifying patterns• Specifically patterns of symbols – A set of rules – A mini language – A tiny, highly specialised programming language• Number one use is for pattern matching – ie: finding things
3. 3. Where could you use this awesome skill?• Python• Perl, C, Java, VB.NET, Javascript• Yahoo Widgets• Excel, Word ….
4. 4. Basic RegEx Syntax[abc] = either a, b or c (class)a|b = a or b[a-z] = anything between a and z[^5] = anything except 5. = anything (except a new line)* = multiple instances of the same char (0->) The backslash is a metacharacter(ab)* Round brackets group chars together .^\$*+?{[]|()
5. 5. Exercise 1Which of the following matches regexp a(ab)*a• abababa• aaba• aabbaa• aba• aabababa
6. 6. Exercise 2• Which of the following matches regexp abc|xyz• abc• xyz• abc|xyz
7. 7. Repetitions• a* = zero or more repetitions of a• a+ = one or more repetitions of a• a? = zero or one repetitions of a – (in other words, might not be there)
8. 8. Exercise 3• Which of the following matches regexp ab+c?• abc• ac• abbb• bbc
9. 9. Exercise 4• Which of the following matches regexp a.[bc]+• abc• abbbbbbbb• azc• abcbcbcbc• ac• asccbbbbcbcccc