Note that there are some explanatory texts on larger screens.

plurals
  1. PORegex - How to search for singular or plural version of word
    primarykey
    data
    text
    <p>I'm trying to do what should be a simple Regular Expression, where all I want to do is match the singular portion of a word whether or not it has an s on the end. So if I have the following words</p> <pre><code>test tests </code></pre> <p>EDIT: Further examples, I need to this to be possible for many words not just those two</p> <pre><code>movie movies page pages time times </code></pre> <p>For all of them I need to get the word without the s on the end but I can't find a regular expression that will always grab the first bit without the s on the end and work for both cases. </p> <p>I've tried the following:</p> <pre><code>([a-zA-Z]+)([s\b]{0,}) - This returns the full word as the first match in both cases ([a-zA-Z]+?)([s\b]{0,}) - This returns 3 different matching groups for both words ([a-zA-Z]+)([s]?) - This returns the full word as the first match in both cases ([a-zA-Z]+)(s\b) - This works for tests but doesn't match test at all ([a-zA-Z]+)(s\b)? - This returns the full word as the first match in both cases </code></pre> <p>I've been using <a href="http://gskinner.com/RegExr/" rel="nofollow">http://gskinner.com/RegExr/</a> for trying out the different regex's.</p> <p>EDIT: This is for a sublime text snippet, which for those that don't know a snippet in sublime text is a shortcut so that I can type say the name of my database and hit "run snippet" and it will turn it into something like:</p> <pre><code>$movies= $this-&gt;ci-&gt;db-&gt;get_where("movies", ""); if ($movies-&gt;num_rows()) { foreach ($movies-&gt;result() AS $movie) { } } </code></pre> <p>All I need is to turn "movies" into "movie" and auto inserts it into the foreach loop. </p> <p>Which means I can't just do a find and replace on the text and I only need to take 60 - 70 words into account (it's only running against my own tables, not every word in the english language). </p> <p>Thanks! - Tim</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. 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