[Solved] allow specif regex only in a block


Ok, first you should probably write your regex as:

[\u0600-\u06FF\uFB8A\u067E\u0686\u06AF \.!?:)(,;1234567890%\-_#]+$

Here %\-_ inside [...] means % or - or _ while your %-_ means “any symbol with the code from % to _. Try /[%-_]/.exec(")") and see what I mean: the ) symbol is in that range. I also put \. which highlights that it is . symbol, not “any symbol”, although just . works correctly in this case.

Now, you’d like to allow emails in the text. Well it’s not a simple task, but for simple cases you may use something like

[\w\-]+@[\w\-\.]+\.\w+

Anyway once you pick the email rexep (may be one of those complicated solutions), you should concatenate it to your regexp like this (I use the simple one shown above):

(?:[\u0600-\u06FF\uFB8A\u067E\u0686\u06AF \.!?:)(,;1234567890%\-_#]|[\w\-]+@[\w\-\.]+\.\w+)+$

This doesn’t handle whitespace, though, meaning that this doesn’t check if there are spaces/tabs/punctuation before and after the email. This means that this text will be valid, too:

<arabic> <arabic> <arabic>email<arabic> <arabic>.
                         /\   /\ no whitespace or punctuation here

4

solved allow specif regex only in a block