Xcode Regex Find and Replace


/ Published in: Other
Save to your folder(s)

This example attempts to reorder pointer declarations so that the asterisk is adjacent to the class name. It searches for a letter, asterisk and space, and a letter. It replaces that group with the initial letter, "* ", and the final letter.

Parentheses in the regular expressions register a group number.

The regular expression used here only matches letters. Add 0-9 in the square brackets to search for numbers as well.


Copy this code and paste it in your HTML
  1. Find: ([a-zA-Z])([* ]{2})([a-zA-Z])
  2. Replace: \1\* \3
  3.  
  4.  
  5.  
  6. Example:
  7. NSString *str
  8. becomes...
  9. NSString* str

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.