Thinking   regular expression  is your way to get started to  use   regular expressions
Mönster sökning vad är regex.
Validering
NOTIS:  12345 , the bugg x
2008-02-21 2008 /03 /  22 20080423 2008  05 24
21-02-2008 22-03-2008 23-04-2008 24-05-2008
(?:(?:
)?[ 	])*(?:(?:(?:[^()<>@,;:amp;quot;.[] �00-�31]+(?:(?:(?:
)?[ 	] )+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(...
 
 
 
^
$
^grey
^ grey
^ g rey
^g r ey
^gr e y
^gre y
^grey$
<ul><li>^grey </li></ul><ul><li>beginning of line  ^ </li></ul><ul><li>followed immediately by  g </li></ul><ul><li>follow...
/ /Everybody get in front/ You know regular expressions
 
[ea] Character Classes
[1234] Character Classes
[1-4] Character Classes
[^1-4] Character Classes
. Any Character
+ Repetition
* Repetition
d Shortcut [0-9]
D Shortcut [^0-9]
() Backreference
.+[?] Questions
 
 
Upcoming SlideShare
Loading in …5
×

Thinking Regular Expressions

2,061 views

Published on

My point is that I think many developers see it as hard/complex to understand and use regular expressions, but by getting the basic thinking right I believe it is really easy to getting started to use this powerful tool. The presentations was supposed to be a kick start.

Note! This presentations is not supposed to stand alone, it is done to support my talk.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,061
On SlideShare
0
From Embeds
0
Number of Embeds
39
Actions
Shares
0
Downloads
45
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Thinking Regular Expressions

  1. 1. Thinking regular expression is your way to get started to use regular expressions
  2. 2. Mönster sökning vad är regex.
  3. 3. Validering
  4. 4. NOTIS: 12345 , the bugg x
  5. 5. 2008-02-21 2008 /03 / 22 20080423 2008 05 24
  6. 6. 21-02-2008 22-03-2008 23-04-2008 24-05-2008
  7. 7. (?:(?: )?[ ])*(?:(?:(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ] )+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:( ?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*))*@(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00- 31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)* ](?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+ (?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?: (?: )?[ ])*))*|(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+| |(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: ) ?[ ])*)*<(?:(?: )?[ ])*(?:@(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: r )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: ) ?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ] )*))*(?:,@(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])* )(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ] )+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*))*) *:(?:(?: )?[ ])*)?(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+ ||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*))*@(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31 ]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*]( ?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(? :(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(? : )?[ ])*))*>(?:(?: )?[ ])*)|(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(? :(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )? [ ]))*&quot;(?:(?: )?[ ])*)*:(?:(?: )?[ ])*(§?:(?:(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; | |(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<> @,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot; (?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*))*@(?:(?: )?[ ] )*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:&quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(? :[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[ ]]))|[([^[] |)*](?:(?: )?[ ])*))*|(?:[^()<>@,;:amp;quot;.[] 00- 31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||( ?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)*<(?:(?: )?[ ])*(?:@(?:[^()<>@,; :amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([ ^[] |)*](?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot; .[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[ ] |)*](?:(?: )?[ ])*))*(?:,@(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;. [] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] r|)*](?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*))*)*:(?:(?: )?[ ])*)?(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; |.|(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@, ;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|&quot;(? :[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*))*@(?:(?: )?[ ])* (?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;. []]))|[([^[] |)*](?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[ ^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[] ]))|[([^[] |)*](?:(?: )?[ ])*))*>(?:(?: )?[ ])*)(?:,s*( ?:(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:&quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)(?:.(?:( ?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[ [&quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*))*@(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*)(? :.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+| |(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*))*|(?: [^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;.[ ]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)*<(?:(?: ) ?[ ])*(?:@(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot; ()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*)(?:.(?:(?: ) ?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<> @,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*))*(?:,@(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@, ;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*)(?:.(?:(?: )?[ ] )*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:&quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*))*)*:(?:(?: )?[ ])*)? (?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[&quot;()<>@,;:amp;quot;. []]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ])*)(?:.(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+||(?=[[ &quot;()<>@,;:amp;quot;.[]]))|&quot;(?:[^&quot; ||(?:(?: )?[ ]))*&quot;(?:(?: )?[ ]) *))*@(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ]) +||(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*)(?: .(?:(?: )?[ ])*(?:[^()<>@,;:amp;quot;.[] 00-31]+(?:(?:(?: )?[ ])+| |(?=[[&quot;()<>@,;:amp;quot;.[]]))|[([^[] |)*](?:(?: )?[ ])*))*>(?:( ?: )?[ ])*))*)?;s*)
  8. 11. ^
  9. 12. $
  10. 13. ^grey
  11. 14. ^ grey
  12. 15. ^ g rey
  13. 16. ^g r ey
  14. 17. ^gr e y
  15. 18. ^gre y
  16. 19. ^grey$
  17. 20. <ul><li>^grey </li></ul><ul><li>beginning of line ^ </li></ul><ul><li>followed immediately by g </li></ul><ul><li>followed immediately by r </li></ul><ul><li>followed immediately by e </li></ul><ul><li>followed immediately by y </li></ul>
  18. 21. / /Everybody get in front/ You know regular expressions
  19. 23. [ea] Character Classes
  20. 24. [1234] Character Classes
  21. 25. [1-4] Character Classes
  22. 26. [^1-4] Character Classes
  23. 27. . Any Character
  24. 28. + Repetition
  25. 29. * Repetition
  26. 30. d Shortcut [0-9]
  27. 31. D Shortcut [^0-9]
  28. 32. () Backreference
  29. 33. .+[?] Questions

×