Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First you need to be explicit about the replacement conditions, your rules say 'not at the begining of a word and not before/after a vowel' but you have not implemented that in the regex. You can do this using Negative Lookahead/Lookbehind. For example:</p> <ol> <li>Replace a, i, o with u (if not at the beginning of a word &amp; if not before/after a vowel)</li> </ol> <p>Can be implemented with:</p> <pre><code>$patterns[] = "/(?&lt;!\b|[aeiou])[aio](?![aeiou])/"; $replacements[] = "u"; </code></pre> <p>This method can be used to implement the first 3 rules.</p> <p>The next problem is that 'fox' and 'dog' will be affected by the first 3 rules, so you should replace the <em>changed</em> version to 'wolf' and 'cat'. So for dog => cat:</p> <pre><code>$patterns[] = "/\bdug\b/"; $replacements[] = "cat"; </code></pre> <p>Note: Because of the way preg_replace works with arrays, it's much better to not use indexes in the $patterns and $replacements arrays, since these can be misleading. Use the [] operator in pairs like I did above, so you always know what goes with what.</p> <p>Part 2:</p> <p>Aha. I see. You need to make the replacement exlusive.</p> <p>You could use a regex that matches both the first cases, which are the problematic ones. Then you can use an interesting weird feature of preg_replace: When you add the <code>e</code> modifier, the replace string is instead evaluated as PHP code. Combining this with capturing groups, it will allow you to decide whether to output a <code>u</code> or an <code>i</code> according to what you matched.</p> <pre><code>$patterns[] = "/(?&lt;!\b|[aeiou])([aeiou])(?![aeiou])/e"; $replacements[] = '("$1" == "e" || "$1" == "u")? "i":"u"'; </code></pre> <p>*Note the /e and the () around the vowel matching class.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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