PDF Table of Contents - PowerGREP

Version 5.3.4 -- 9 January 2024

Published by Just Great Software Co. Ltd. Copyright ? 2002?2024 Jan Goyvaerts. All rights reserved. "PowerGREP" and "Just Great Software" are trademarks of Jan Goyvaerts

i

Table of Contents

How to Use PowerGREP......................................................................................1

1. Introducing PowerGREP.............................................................................................................................................. 3 2. Contact PowerGREP's Developer and Publisher..................................................................................................... 4 3. Getting Started with PowerGREP............................................................................................................................... 5 4. Mark Files for Searching................................................................................................................................................ 7 5. Define a Search Action................................................................................................................................................ 10 6. Interpret Search Results............................................................................................................................................... 13 7. Edit Files and Replace or Revert Individual Matches............................................................................................. 15 8. Keyboard Shortcuts...................................................................................................................................................... 16 9. Regular Expressions Quick Start................................................................................................................................ 17

PowerGREP Examples .......................................................................................23

1. Search Through File Names ....................................................................................................................................... 25 2. Find Files Not Containing a Search Term................................................................................................................ 27 3. Find Email Addresses .................................................................................................................................................. 28 4. How to Find Word Pairs ............................................................................................................................................. 30 5. Boolean Operators "and", "or", and "not".............................................................................................................. 31 6. Find Two Words Near Each Other .......................................................................................................................... 35 7. Find Two or More Words on The Same Line ......................................................................................................... 36 8. Search Through Microsoft Word Documents......................................................................................................... 37 9. Search and Replace Through Microsoft Word Documents .................................................................................. 39 10. Search Through PDF Files ....................................................................................................................................... 42 11. Search Through XPS and OXPS Files.................................................................................................................... 44 12. Search Through OpenOffice and LibreOffice Writer Documents.................................................................... 45 13. Search Through OpenDocument Format Files .................................................................................................... 46 14. Search Through Spreadsheets .................................................................................................................................. 48 15. Update Hyperlinks in Microsoft Office Files ........................................................................................................ 49 16. Search and Edit Audio File Meta Data ................................................................................................................... 50 17. Rename Audio Files Using Meta Data.................................................................................................................... 51 18. Search and Edit EXIF and IPTC Image Meta Data............................................................................................. 52 19. Search (and Replace) through RTF and HTML as Plain Text............................................................................ 54 20. Search Through Mailboxes And Email Messages ................................................................................................. 55 21. Search Through ZIP Files And Other Archives ................................................................................................... 58 22. Search Through UOT Files ...................................................................................................................................... 59 23. Extract or Delete Lines Matching One or More Strings or Regexes ................................................................. 60 24. How to Delete Repeated Words .............................................................................................................................. 61 25. Add a Header and Footer to Files ........................................................................................................................... 62 26. Add Line Numbers .................................................................................................................................................... 63 27. Collect Page Numbers ............................................................................................................................................... 65 28. Update Copyright Years ............................................................................................................................................ 66 29. Padding Replacements............................................................................................................................................... 68 30. Capitalize The First Letter of Each Word.............................................................................................................. 69 31. Convert Text File Encoding And Line Break Style .............................................................................................. 70

ii

32. Convert Files in Proprietary Formats to Plain Text ............................................................................................. 71 33. Find Bytes That Are Not Part of Valid UTF-8 Sequences.................................................................................. 72 34. Replace in File Names and Contents ...................................................................................................................... 73 35. Add Proper HTML Tags ...................................................................................................................... 74 36. Rename Files Based on HTML Title Tags ............................................................................................................. 76 37. Replace HTML Tags.................................................................................................................................................. 78 38. Replace HTML Attributes ........................................................................................................................................ 79 39. Put Anchors Around URLs That Are Not Already Inside a Tag or Anchor ................................................... 80 40. Replacing Named XML Entities.............................................................................................................................. 81 41. Fix Invalid Characters in XML................................................................................................................................. 83 42. Search Through or Skip Source Code Comments and Strings ........................................................................... 85 43. Convert Windows to UNIX Paths .......................................................................................................................... 87 44. Extract Data into a CSV File or Spreadsheet ........................................................................................................ 88 45. Padding and Unpadding CSV Files ......................................................................................................................... 90 46. Collect a Numbered List ........................................................................................................................................... 91 47. Collect a List of Header and Item Pairs.................................................................................................................. 92 48. Collect Paragraphs (Split along Blank Lines) ......................................................................................................... 94 49. Process Files in a Batch File or Script..................................................................................................................... 95 50. Apply an Extra Search-And-Replace to Target Files............................................................................................ 96 51. Inspect Web Logs....................................................................................................................................................... 97 52. Extract Google Search Terms from Web Logs..................................................................................................... 99 53. Split Web Logs by Date...........................................................................................................................................100 54. Merge Web Logs by Date ....................................................................................................................................... 102 55. Split Logs into Files with a Certain Number of Entries .................................................................................... 103 56. Split Database Dumps ............................................................................................................................................. 105 57. Compile Indices of Files..........................................................................................................................................107 58. Make Sections and Their Contents Consistent....................................................................................................108 59. Generate a PHP Navigation Bar............................................................................................................................110 60. Include a PHP Navigation Bar...............................................................................................................................112

PowerGREP Reference ..................................................................................... 113

1. PowerGREP Assistant...............................................................................................................................................115 2. File Selector Reference .............................................................................................................................................. 117 3. Import File Listings....................................................................................................................................................124 4. File Format Configuration ........................................................................................................................................ 127 5. Archive Format Configuration ................................................................................................................................. 132 6. Text Encoding Configuration...................................................................................................................................136 7. Hide Files and Folders ............................................................................................................................................... 141 8. File Selector Menu......................................................................................................................................................143 9. Action Reference ........................................................................................................................................................150 10. Action Types .............................................................................................................................................................152 11. Search Terms and Options ..................................................................................................................................... 160 12. Action Part: Filter Files............................................................................................................................................ 167 13. Action Part: File Sectioning .................................................................................................................................... 171 14. Main Part of The Action ......................................................................................................................................... 176 15. Action Part: Extra Processing ................................................................................................................................ 178 16. Action Part: Context ................................................................................................................................................ 179 17. Action Part: Collect Between .................................................................................................................................182 18. Action Part: Target and Backup Files ................................................................................................................... 185

iii

19. Action Parts and Named Capture..........................................................................................................................191 20. Action Menu..............................................................................................................................................................193 21. Sequence Reference.................................................................................................................................................. 197 22. Sequence Menu ......................................................................................................................................................... 200 23. Library Reference .....................................................................................................................................................205 24. Library Menu.............................................................................................................................................................207 25. Results Reference ..................................................................................................................................................... 209 26. Results Menu.............................................................................................................................................................212 27. Editor Reference.......................................................................................................................................................220 28. Editor Menu .............................................................................................................................................................. 223 29. Undo History Reference ......................................................................................................................................... 228 30. Undo History Menu ................................................................................................................................................. 230 31. Change PowerGREP's Appearance and Layout ................................................................................................. 232 32. Share Experiences and Get Help on The User Forums .................................................................................... 236 33. Forum RSS Feeds.....................................................................................................................................................242 34. File Selector Preferences ......................................................................................................................................... 243 35. Action Preferences ................................................................................................................................................... 245 36. Text Layout Configuration ..................................................................................................................................... 248 37. Text Cursor Configuration......................................................................................................................................253 38. Color Configuration.................................................................................................................................................256 39. Results Preferences...................................................................................................................................................260 40. Editor Preferences....................................................................................................................................................262 41. External Editors Preferences..................................................................................................................................265 42. General Preferences ................................................................................................................................................. 268 43. Cache Preferences ....................................................................................................................................................271 44. Match Placeholders .................................................................................................................................................. 274 45. Path Placeholders ..................................................................................................................................................... 282 46. Command Line Parameters .................................................................................................................................... 285 47. Command Line Examples.......................................................................................................................................294 48. XML Format of PowerGREP Files ......................................................................................................................298

Regular Expression Tutorial.............................................................................299

1. Regular Expressions Tutorial....................................................................................................................................301 2. Literal Characters........................................................................................................................................................302 3. Non-Printable Characters..........................................................................................................................................304 4. First Look at How a Regex Engine Works Internally .......................................................................................... 305 5. Character Classes or Character Sets......................................................................................................................... 307 6. Character Class Subtraction ......................................................................................................................................309 7. Character Class Intersection ..................................................................................................................................... 310 8. Shorthand Character Classes .................................................................................................................................... 311 9. The Dot Matches (Almost) Any Character ............................................................................................................ 312 10. Start of String and End of String Anchors...........................................................................................................314 11. Word Boundaries......................................................................................................................................................317 12. Alternation with The Vertical Bar or Pipe Symbol ............................................................................................. 319 13. Optional Items .......................................................................................................................................................... 321 14. Repetition with Star and Plus ................................................................................................................................. 322 15. Use Parentheses for Grouping and Capturing.....................................................................................................325 16. Using Backreferences To Match The Same Text Again .................................................................................... 326 17. Backreferences to Failed Groups...........................................................................................................................329

iv

18. Named Capturing Groups and Backreferences...................................................................................................331 19. Branch Reset Groups...............................................................................................................................................333 20. Free-Spacing Regular Expressions.........................................................................................................................335 21. Unicode Regular Expressions.................................................................................................................................337 22. Specifying Modes Inside The Regular Expression..............................................................................................344 23. Atomic Grouping ..................................................................................................................................................... 345 24. Possessive Quantifiers ............................................................................................................................................. 347 25. Lookahead and Lookbehind Zero-Length Assertions .......................................................................................349 26. Testing The Same Part of a String for More Than One Requirement ............................................................352 27. Keep The Text Matched So Far out of The Overall Regex Match..................................................................354 28. If-Then-Else Conditionals in Regular Expressions ............................................................................................ 356 29. Matching Nested Constructs with Balancing Groups ........................................................................................ 359 30. Regular Expression Recursion ............................................................................................................................... 363 31. Regular Expression Subroutines ............................................................................................................................ 364 32. Infinite Recursion ..................................................................................................................................................... 367 33. Quantifiers On Recursion .......................................................................................................................................368 34. Subroutine Calls May or May Not Capture..........................................................................................................370 35. Backreferences That Specify a Recursion Level .................................................................................................. 374 36. Recursion and Subroutine Calls May or May Not Be Atomic .......................................................................... 377 37. POSIX Character Classes........................................................................................................................................380 38. Zero-Length Regex Matches .................................................................................................................................. 382 39. Continuing at The End of The Previous Match..................................................................................................384 40. Replacement Strings Tutorial ................................................................................................................................. 385 41. Special Characters.....................................................................................................................................................387 42. Non-Printable Characters .......................................................................................................................................388 43. Matched Text ............................................................................................................................................................ 389 44. Numbered and Named Backreferences ................................................................................................................ 390 45. Match Context .......................................................................................................................................................... 392 46. Replacement Text Case Conversion......................................................................................................................393 47. Replacement String Conditionals...........................................................................................................................394

Regular Expression Examples..........................................................................397

1. Sample Regular Expressions ..................................................................................................................................... 399 2. Matching Numeric Ranges with a Regular Expression ........................................................................................ 401 3. Matching Floating Point Numbers with a Regular Expression .......................................................................... 403 4. How to Find or Validate an Email Address ........................................................................................................... 404 5. How to Find or Validate an IP Address .................................................................................................................409 6. Matching a Valid Date ............................................................................................................................................... 411 7. Replacing Numerical Dates with Textual Dates....................................................................................................412 8. Finding or Verifying Credit Card Numbers ........................................................................................................... 414 9. Matching Whole Lines of Text.................................................................................................................................416 10. Deleting Duplicate Lines From a File...................................................................................................................418 11. Example Regexes to Match Common Programming Language Constructs ..................................................419 12. Find Two Words Near Each Other ...................................................................................................................... 422 13. Runaway Regular Expressions: Catastrophic Backtracking...............................................................................423 14. Runaway Regular Expressions: Too Many Repetitions ..................................................................................... 430 15. Preventing Regular Expression Denial of Service (ReDoS)..............................................................................433 16. Repeating a Capturing Group vs. Capturing a Repeated Group ...................................................................... 437 17. Mixing Unicode and 8-bit Character Codes.........................................................................................................439

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download