I’m using the following expression:
/^[alopinme]{5}$/
This regexp take me words from a set of words with letters contained within the brackets.
well, now i need to add some more functionality to such expression because i need that the fetched words could contain ONLY one more letter from another set of letters. Let’s say that i want to get words formed with letters from set A and could (if exist) contain one more letter from set B.
i’m trying to guess how could i complete my regular expression but i do not find the right way.
Anyone could help me?
Thanks.
EDIT:
Here i post an example:
SELECT sin_acentos FROM Finder.palabras_esp WHERE sin_acentos REGEXP '^[tehsolm]{5}$'
This expression choose me words like: helms, moths meths homes and so on…..
but i need to add a set B of letters and get words that could contain ONLY one from such set. Lets say I have another set of letters [xzk] so the expression could get more words but only with the possibility of choosing one letter from set B.
The result could get words like: mozes, hoxes, tozes, and so on… if you check such words, you can see that most of letters for every word are from set A but only one from set B.
If the one of the other characters should appear exactly once, you can use:
(?=.{5}$)– Check the string is 5 characters long, even before matching. (this might not work on MySql)[alopinme]*– Characters from A(?:[XYZ][alopinme]*)?– Optional – one character from B, and some more from A.Working example: http://rubular.com/r/aw6l561Int
Or, for if you want them up to 3 times, for example: