1 / 14

ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS

ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS. CHRISTOPHER ZACK | OMNIUPDATE. Agenda. ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS. Find & Replace History of Regular Expressions Literal Character Search Special Characters Period Quantifiers Parentheses Square Brackets

mccullough
Download Presentation

ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS CHRISTOPHER ZACK|OMNIUPDATE

  2. Agenda • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Find & Replace • History of Regular Expressions • Literal Character Search • Special Characters • Period • Quantifiers • Parentheses • Square Brackets • Shorthand Character Classes • Greedy Matches

  3. Find & Replace • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Location: Content > Find and Replace • Administrators Only (User Level 10) • Searches a single site • Adjust scope to limit searchable content • Literal Text or Regular Expression

  4. Find & Replace • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Find • Simple search with results list. • Preview Replace • Safe multi-step process • Perform ‘sample’ find/replace and display results list. • Select pages from results to perform the actual find/replace operation. • Publish selected results (optional).

  5. History of Regular Expressions • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Regular Expression • A pattern that describes a certain amount of text. • The concept arose in the 1950s when the American mathematician Stephen Cole description of a regular language. • Now used in almost every major programming language.

  6. Literal Character Search • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Literal Text Matches • Most characters match exactly themselves (beware of whitespace) • Case Sensitive • Great way to get a general idea of how many items will at least need to be captured if you need to generate a regular expression “find.”

  7. Special Characters • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS Symbol characters that have special purpose: \ ^ $ . | ? * ( ) [ ] { } To match as literal characters, you must escape them by adding a backslash “\” in front of said special character.

  8. Special Characters: Period • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • The period character is the “wildcard” character • Will match any character except a newline (\n)

  9. Special Characters: Quantifiers • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Symbol characters that define how many of the previous character(s) to match • ? (0 or 1) • * (0 or more) • + (1 or more) • Use curly brackets to indicate an exact number or range • {3} (Exactly 3) • {3,} (3 or more) • {3,5} (3, 4, or 5) • Only modifies the previous character (or group)

  10. Special Characters: Parenthesis • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Capture Groups • Encapsulate a character sequence using parentheses: “(…)” • Add a quantifier to affect the whole group • Replace • In the “replace field,” refer to your groups using the dollar sign and then the group number: $# • Count the opening parenthesis characters, “(“, to determine the correct #

  11. Special Characters: Square Brackets • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Character Sets • Characters encased inside square brackets define all possible matches for a single text character: [abc] • A quantifier place directly after the set will affect the whole character set • Placing a “-” hyphen between characters indicates a range • Placing a “^” caret as the first item in the set creates a negative pattern • Quantifier characters become literal matches: ? + * { } • Placing a “.” period becomes literal match

  12. Shorthand Character Classes • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • Certain characters can reference a range of characters when escaped by a backslash “\” • Examples: • “\d” matches all digit characters: [0-9] • “\w” matches all word characters: [A-Za-z0-9] • “\s” matches all whitespace characters (including line breaks) • Using the capital letter will inverse the match • “\S” matches all non-space characters: [^\s]

  13. Greedy Matches • ADVANCE FIND & REPLACE WITH REGULAR EXPRESSIONS • When using quantifiers, a careless (or purposeful) pattern could match beyond an expected result • Applying an extra “?” question mark character after the initial quantifier, to make the pattern stop at the first successful match • [\s\S]*?

  14. THANK YOU! PLEASE SHARE YOUR FEEDBACK: WWW.SLIDO.COM#OUTC19

More Related