Answers.Body: <p>I'll add my two cents here, since it appears you are removing Wordpress created images (which I also did).</p>
  
  <p>I wrote a regex initially to find all these duplicated files (this command works specifically on OSX, but is pretty portable):</p>
  
  <pre><code>find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$'
  </code></pre>
  
  <p>I then wrote a minor change to delete them:</p>
  
  <pre><code>find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$' -delete
  </code></pre>
  
  <p>I figure you can use this same regex pattern to find/replace in a database dump locally, which this answer here points to: <a href="https://stackoverflow.com/a/9456574/776167">https://stackoverflow.com/a/9456574/776167</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-19T14:11:39.280Z
Answers.LastActivityDate: 2017-12-19T14:11:39.280Z
Answers.UserDisplayName: hisnameisjimmy
Answers.Body: <p>Nope, because MySQL doesn't support RegEx replacements in SQL statements.  It's been an <a href="http://bugs.mysql.com/bug.php?id=27389" rel="nofollow">open feature request</a> since 2007, so feel free to add your vote.</p>
  
  <p>There are some potential workarounds <a href="https://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql">listed here</a>, too.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-12-19T15:06:43.647Z
Answers.Text: As of MariaDB 10+ regex is supported, would be really nice to include this in CraftCMS 3 as an option for MariaDB users: https://stackoverflow.com/a/26179601/776167
Answers.UserDisplayName: hisnameisjimmy
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-30T23:47:22.333Z
Answers.Text: Yeah the more I researched, the less hope I had that there was a solution for it. Guess the easiest would be to dump out the db & do in directly in my IDE?
Answers.UserDisplayName: Seán O'Grady
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-01T07:15:13.603Z
Answers.Text: Yeah, that's what I'd do.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-30T21:57:12.473Z
Answers.LastActivityDate: 2014-06-30T22:44:22.270Z
Answers.LastEditDate: 2014-06-30T22:44:22.270Z
Answers.UserDisplayName: Brad Bell
Body: <p>Does the Find and Replace tool support regex? I need to remove a certain section of an image url for all images in the 'field_body' column.</p>
  
  <p>So if I had an image referenced as such </p>
  
  <pre><code>http://craft.dev/uploads/image-600x400.png
  </code></pre>
  
  <p>I would be able to find all images that match that pattern and return the url to be </p>
  
  <pre><code>http://craft.dev/uploads/image.png
  </code></pre>
  
  <p>Now I have very little experience with Regex but would this be a safe pattern to use (if I can with Craft that is...)?</p>
  
  <pre><code>(-[0-9]+x[0-9]+)
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-27T16:49:29.847Z
Comments.Text: We already had a very similar question: ["How can I perform a RegEx match in Twig?"](http://craftcms.stackexchange.com/q/228/125)
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-27T16:53:41.957Z
Comments.Text: Thanks. It is similar I guess, but not entirely the same. I want to permanently replace the content rather than to rely on using twig for something like this. The URL's shouldnt need to change after this replacement process.
Comments.UserDisplayName: Seán O'Grady
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-27T18:46:02.960Z
Comments.Text: Sorry, did't read this properly. So your actual files are already renamed and now you want to change that in the db, right? What about using Sequel or sth. to change that in the db directly?
Comments.UserDisplayName: carlcs
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-27T19:02:23.237Z
Comments.Text: Sort of. The images were generated by Wordpress from the source image and I want to reference that source image instead of the smaller image, otherwise I'll have 40k photos that I will never use! I could do it directly in the db I guess!
Comments.UserDisplayName: Seán O'Grady
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-27T22:52:35.233Z
Comments.Text: Just another question. What is sth? Also does Sequel Pro (I'm guessing that's what you meant) allow regex replacement? I know native MySQL doesnt allow it,
Comments.UserDisplayName: Seán O'Grady
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-06-28T10:06:21.437Z
Comments.Text: Yes I meant Sequel Pro or sth. (=something :)) like that. Sorry for confusion, also a quick google search made me aware of the fact, that there is no built-in regex functionality in MYSQL or Sequel Pro. There are plugins available, but maybe this is all a little overkill for your single task. I'd rather export that single table and use an external app for the regex (I have no experience with that). I suppose you already entered content to some asset fields and/or related your assets to entries, so that a reimport of your full-size assets is no option?!
Comments.UserDisplayName: carlcs
Tags: <regex>
Title: Can I use Regex in the Find and Replace tool?
ThreadText: # Can I use Regex in the Find and Replace tool?
  
  (Asked by: username_0 on 2014-06-27)
  
  Does the Find and Replace tool support regex? I need to remove a certain section of an image url for all images in the 'field\_body' column.
  
  So if I had an image referenced as such
  
  ```
  http://craft.dev/uploads/image-600x400.png
  
  ```
  
  I would be able to find all images that match that pattern and return the url to be
  
  ```
  http://craft.dev/uploads/image.png
  
  ```
  
  Now I have very little experience with Regex but would this be a safe pattern to use (if I can with Craft that is...)?
  
  ```
  (-[0-9]+x[0-9]+)
  
  ```
  
  **Tags:** regex
  
  > **Comments:**
  > **username_1**: We already had a very similar question: ["How can I perform a RegEx match in Twig?"](http://craftcms.stackexchange.com/q/228/125)  
  > **username_0**: Thanks. It is similar I guess, but not entirely the same. I want to permanently replace the content rather than to rely on using twig for something like this. The URL's shouldnt need to change after this replacement process.  
  > **username_1**: Sorry, did't read this properly. So your actual files are already renamed and now you want to change that in the db, right? What about using Sequel or sth. to change that in the db directly?  
  > **username_0**: Sort of. The images were generated by Wordpress from the source image and I want to reference that source image instead of the smaller image, otherwise I'll have 40k photos that I will never use! I could do it directly in the db I guess!  
  > **username_0**: Just another question. What is sth? Also does Sequel Pro (I'm guessing that's what you meant) allow regex replacement? I know native MySQL doesnt allow it,  
  > **username_1**: Yes I meant Sequel Pro or sth. (=something :)) like that. Sorry for confusion, also a quick google search made me aware of the fact, that there is no built-in regex functionality in MYSQL or Sequel Pro. There are plugins available, but maybe this is all a little overkill for your single task. I'd rather export that single table and use an external app for the regex (I have no experience with that). I suppose you already entered content to some asset fields and/or related your assets to entries, so that a reimport of your full-size assets is no option?!  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2014-06-30. Score: 6 | Accepted answer
  
  Nope, because MySQL doesn't support RegEx replacements in SQL statements. It's been an [open feature request](http://bugs.mysql.com/bug.php?id=27389) since 2007, so feel free to add your vote.
  
  There are some potential workarounds [listed here](https://stackoverflow.com/questions/986826/how-to-do-a-regular-expression-replace-in-mysql), too.
  
  > **Comments:**
  > **username_0**: Yeah the more I researched, the less hope I had that there was a solution for it. Guess the easiest would be to dump out the db & do in directly in my IDE?  
  > **username_3**: Yeah, that's what I'd do.  
  > **username_2**: As of MariaDB 10+ regex is supported, would be really nice to include this in CraftCMS 3 as an option for MariaDB users: https://stackoverflow.com/a/26179601/776167  
  
  ---
  
  ### Answer by username_2 on 2017-12-19. Score: 1
  
  I'll add my two cents here, since it appears you are removing Wordpress created images (which I also did).
  
  I wrote a regex initially to find all these duplicated files (this command works specifically on OSX, but is pretty portable):
  
  ```
  find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$'
  
  ```
  
  I then wrote a minor change to delete them:
  
  ```
  find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$' -delete
  
  ```
  
  I figure you can use this same regex pattern to find/replace in a database dump locally, which this answer here points to: <https://stackoverflow.com/a/9456574/776167>
  
  
  ---
  
  