Skip to content

Instantly share code, notes, and snippets.

@NaanProphet
Created January 4, 2016 22:41
Show Gist options
  • Save NaanProphet/5cc6748f899ab725e4d1 to your computer and use it in GitHub Desktop.
Save NaanProphet/5cc6748f899ab725e4d1 to your computer and use it in GitHub Desktop.
Regex Pojos
Notepad++ Regex for replacing malicious dates in POJOs
note: . matches newline must NOT be checked
Only meant for Notepad++, have to open the files from Explorer and then click Refresh in Eclipse afterwards.
May not be 100% foolproof! Imperative to review the files manually!
Note: before replacing, use the "Mark All" feature in Notepad++ with "Bookmark line" checked. Then after replacing, jump to the next bookmark using F2 (and Shift+F2)
********************
For Getters
Find:
(public Date get\w*?\(\)\s\{\s*?\n\s.*?return )(?!ObjectUtils)(\w*?)(;)$
Replace:
\1ObjectUtils.clone\(\2\)\3
For Setters
Find:
(public void set\w+?\(Date \w+?\) \{\s*?\n\s.*? = )(?!ObjectUtils)(\w*)(;)$
Replace:
\1ObjectUtils.clone\(\2\)\3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment