Computer Programming 2 - PowerPoint PPT Presentation

computer programming 2 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Computer Programming 2 PowerPoint Presentation
Download Presentation
Computer Programming 2

play fullscreen
1 / 12
Computer Programming 2
135 Views
Download Presentation
oleg
Download Presentation

Computer Programming 2

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY (CST) KHANYOUNIS- PALESTINE Computer Programming 2 Lecture 7: String Processing Part d: Regular Expressions Prepared & Presented by: Mahmoud Rafeek Alfarra

  2. و من يتقِ الله ... قال ابن مسعود رضي الله عنه في قوله تعالى : (( اتَّقُوا اللَّهَ حَقَّ تُقَاتِهِ وَلا تَمُوتُنَّ )) (آل عمران :102) قال : أن يطاع فلا يعصي ويذكر فلا ينسى وأن يشكر فلا يكفر. شريحـة ثابتـة لعلنا نحسن من خلالها أخلاقنـا و أفعالنا لنفوز يوم الامتحان الحقيقي Downloaded from http://staff.cst.ps/mfarra

  3. Out Lines • Regular Expressions ,What and why ? • Introduction • Constructors • Count Tokens • Print Tokens • Token Processing Downloaded from http://staff.cst.ps/mfarra

  4. What is Regular expressions? • Regular expressions are sequences of characters and symbols that define a set of strings. • They are useful for validating input and ensuring that data is in a particular format. Downloaded from http://staff.cst.ps/mfarra

  5. Regular expressions Application • A large and complex regular expression is used to validate the syntax of a program. • If the program code does not match the regular expression, the compiler knows that there is a syntax error within the code. Downloaded from http://staff.cst.ps/mfarra

  6. Regular expressions: Special symbols • A regular expression consists of literal characters and special symbols. Downloaded from http://staff.cst.ps/mfarra

  7. Regular expressions: Quantifiers Downloaded from http://staff.cst.ps/mfarra

  8. Regular expressions: Examples • [A-Z][a-z]+matches Ahmad, Zain • \\d{5} matches the Zip address as 12345, 34562,… • [1-9]\\d{2}-[1-9]\\d{2}-\\d{4} as 132 – 354 -6759 • [059][5|7|8|9]\\d{6} as 0597457687, 0595654532 Downloaded from http://staff.cst.ps/mfarra

  9. Regular expressions: Validating Example • Write a program to receive the information of an student, and then print them, Taking into account the: • First and Last name must start with capital letter. • Mobile number must be started with 059, and the 4’th digit must be one of (5,7,8, 9) numbers, and the tottal number of digits is 10 digits. • The Id of male must start with 1 and of female with 2 • Other constraints … Downloaded from http://staff.cst.ps/mfarra

  10. Validating Example: Snapshot Downloaded from http://staff.cst.ps/mfarra

  11. More More about RegExp Chapter 29 in the textbook And http://staff.cst.ps/mfarra Downloaded from http://staff.cst.ps/mfarra

  12. Next Lecture … Introduction to OOP How to develop by? Downloaded from http://staff.cst.ps/mfarra