Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use this</p> <pre><code>$result = preg_replace('/(?&lt;=[a-z_])\s+(?=\d)|(?&lt;=\d)\s+(?=[a-z_])/i', ',', $subject); </code></pre> <p><strong>Explanation</strong></p> <pre><code> # Match either the regular expression below (attempting the next alternative only if this one fails) (?&lt;= # Assert that the regex below can be matched, with the match ending at this position (positive lookbehind) [a-z_] # Match a single character present in the list below # A character in the range between “a” and “z” # The character “_” ) \s # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) + # Between one and unlimited times, as many times as possible, giving back as needed (greedy) (?= # Assert that the regex below can be matched, starting at this position (positive lookahead) \d # Match a single digit 0..9 ) | # Or match regular expression number 2 below (the entire match attempt fails if this one fails to match) (?&lt;= # Assert that the regex below can be matched, with the match ending at this position (positive lookbehind) \d # Match a single digit 0..9 ) \s # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) + # Between one and unlimited times, as many times as possible, giving back as needed (greedy) (?= # Assert that the regex below can be matched, starting at this position (positive lookahead) [a-z_] # Match a single character present in the list below # A character in the range between “a” and “z” # The character “_” ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload