I'll do you one better, and help you learn a little regex. grin

Take your statement you have: /(\:|;)(-)?(P|X|D|\/|\\|\[|\])/ig and break it down:

/(\:|;)(-)?(P|X|D|\/|\\|\[|\])/ig

/ /ig
The two ends and just to specify it is a regex pattern.

(\:|;)
Here we specify the "eyes" of the face. The parenthesis contain all the possible eye combinations seperated by a pipe (| character). The colon is prefixed with a \ because it means something to regex, but we want the literal ':' character.
So to add more eyes, add them between the parenthesis seperated by the pipe (|). In this case, you would like = signs, so this becomes (\:|;|=)

(-)?
This section is for the optional nose (the question mark after the parenthesis means it may or may not be present). Again, if you'd like to add more, add them seperated by a pipe (|) in the parenthesis.

(P|X|D|\/|\\|\[|\])
This is the mouth of the face. Again, all seperated by the pipe (|). What is different here is things such as other parenthesis and brackets are prefixes with a backslash. This is for the same reason as the colon above. Add more mouths seperated by the pipe (|) to this list (you wanted the o, x and pipe, so we would update to look like this: (P|X|D|\/|\\|\[|\]|O|X|\|) -- notice how we escape the pipe cool)

finished product
So now, will the modifications we've done, your end product should look like this: /(\:|;|=)(-)?(P|X|D|\/|\\|\[|\]|O|X|\|)/ig Place that in your $regex() expression and you should be doing great.


To help you out, here are a list of characters you need to prefix with a backslash when adding them to the regular expression: [ ] \ ^ $ . | ? * + ( ) When adding any of these as a possible portion to a face, use a backslash then the character (example: \$ or \.)

Hope that helps. If you have any more questions please ask.


-KingTomato