Your SlideShare is downloading. ×
0
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Kodar-lan - Text and editors Regular expression
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Kodar-lan - Text and editors Regular expression

329

Published on

A lecturea about the basics in regular expression.

A lecturea about the basics in regular expression.

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
329
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Tim Gremalm Developer at Conmel Data AB Programming, Web, Databases, Windows/Linux, Servers, Network, TCP/IP, Robotics, Electronics tim@gremalm.se http://tim.gremalm.se Lecture - Regular expression (Tim Gremalm)
  • 2. Regular expression ● A string that forms a searchpattern ● The basics of regex started in the 1950's ● Used in many UNIX-tools like grep, ed, awk ● Most programming languages supports regular expressions ● Also called regex, regexp Lecture - Regular expression (Tim Gremalm)
  • 3. Common uses of regular expression ● Match a text with a searchpattern for validation ● Search replace (substitute) text ● Syntax-highlighting in editors ● Extracting relevant parts of a text Lecture - Regular expression (Tim Gremalm)
  • 4. Regular expression Match literary Special Characters Carriage return + Tab + v Vertical tab + f Form feed + a Alarm [b] Backspace e Escape N{name} Lecture - Regular expression (Tim Gremalm) New line + t Just enter you text like: yoursearchterm n r ● Escape Character + Named Character
  • 5. Regular expression Anchors ● Position your search term Anchors ^ End of string + Word boundary + Not word boundary + Start of word > Lecture - Regular expression (Tim Gremalm) End of line + < bStartOfWord $ B ● Start of string + b ^StartOfLine A Z ● Start of line + End of word
  • 6. Regular expression Character Classes Character Classes ● Specify a [class] to search for Control character s White space S Not white space d Digit D Not digit w Word W Not word xhh Hexadecimal character hh Oxxx Lecture - Regular expression (Tim Gremalm) c Octal character xxx
  • 7. Regular expression Quantifiers Quantifiers * Lecture - Regular expression (Tim Gremalm) 1 or more, ungreedy + 0 or 1 + 0 or 1, ungreedy + Exactly 3 + 3 or more + 3, 4 or 5 + {3,5}? l* +? {3,5} ● 1 or more + {3,} [d]+ + {3} ● 0 or more, ungreedy + ?? Specify how many times a class may occur *? ? ● 0 or more + 3, 4 or 5, ungreedy +
  • 8. Regular expression Ranges Ranges . Lecture - Regular expression (Tim Gremalm) [abc] Range (a or b or c) + Not a or b or c + Letter between a and q + Upper case letter + between A and Q + Digit between 0 and 7 + n [a-zA-Z] Passive Group + [0-7] ● Group + [A-Q] [A-E] (...) [a-q] ● a or b + [^abc] Specify a class even further (a|b) (?:...) ● Any character except new line (n) + nth group/subpattern +
  • 9. Regular expression Groups ● Extract several parts of a text at the same time ● ^(.*).(.*)$ ● (filename).(Fileextension) Lecture - Regular expression (Tim Gremalm)
  • 10. Links ● http://regex101.com/ - Online regex parser ● http://regexpal.com/ - Online regex parser ● http://gskinner.com/RegExr/ - Online regex parser ● http://www.txt2re.com/ - Help you build regex ● http://www.myezapp.com/apps/dev/regexp/show.ws - Help you analyze the regex-syntax in words Lecture - Regular expression (Tim Gremalm)

×