PHP preg_replace how to combine these two preg statements?


$str = preg_replace('/[\\r\\n!.,\'“”;’?-\s+]/', ' ', $str); $str=preg_replace('/\s+\S{1,2}(?!\S)|(?<!\S)\S{1,2}\s+/', '', $str);

If I leave them like that is there performance issue also or is it better.?


preg_replace accepts arrays as arguments. The following should be equivalent:

$str = preg_replace(array('/[\\r\\n!.,\'“”;’?-\s+]/', '/\s+\S{1,2}(?!\S)|(?<!\S)\S{1,2}\s+/'), array(' ', ''), $str);


  • RegEx for Phone Number Numbers with Letters
  • php regex remove digits
  • Grails eager fetch doesn't retrieve all data
  • Exposing an enum in a QML signal
  • Rx produce and consume on different threads
  • C# Remove URL from String
  • Autohotkey script running program with command line arguments
  • Mongodb update() vs. findAndModify() performace
  • Replace and retrieve placeholder value
  • Entity Framework ObjectContext: Concurrency
  • It is possible use the same sql azure instance from two different cloud service of two different sub
  • How dotnet build chooses the output name
  • Want to understand iframe breakout code
  • Converter from SAT to 3-SAT
  • Excel VBA How to populate a multi-dimensional (3d) array with values from multiple excel ranges?
  • Passing variable arguments using PowerShell's Start-Process cmdlet
  • hide missing dates from x-axis ggplot2
  • Parse a date string in a specific locale (not timezone!)
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Row Count Is Returning the incorrect number using RaptureXML
  • Display issues when we change from one jquery mobile page to another in firefox
  • Illegal mix of collations for operation for date/time comparison
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Different response to non-authenticated users and AJAX calls
  • MySQL WHERE-condition in procedure ignored
  • How to handle AllServersUnavailable Exception
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Rearranging Cells in UITableView Bug & Saving Changes
  • 0x202A in filename: Why?
  • Data Validation Drop Down Box Arrow Disappearing
  • Benchmarking RAM performance - UWP and C#
  • Angular 2 constructor injection vs direct access
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Python/Django TangoWithDjango Models and Databases
  • java string with new operator and a literal