locked
Problem in regex validation to match Arabic with English text multiline RRS feed

  • Question

  • User-1665696529 posted
    Greeting
    I search long time and test many formula to validate Arabic character.
    Scenario describe:
    I have a form contain a Text box (title) and another text box field (description)
    I designed a form to allow user to write in both languages (Arabic or English ) or in some time a paragraph containing both of last languages.
     -Text box mode(Multiline).
    -Accept (Arabic & English) with spaces and new line(Enter).
    first time I used this formula for my propose:
      
    I followed that post 
    1. ^[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFa-zA-Z]+[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFa-zA-Z-_]*$  
     But last formula not work correctly.
    I moved to another formula like this
    1. ^[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFa-zA-Z\s\w*]  
     and problem still as it.
    what anyone have an idea to describe what happening?
     
    thanks 
    Monday, April 19, 2021 3:43 PM

Answers

  • User1535942433 posted

    Hi aktham85,

    As far as I think,[a-zA-Z] is English character and [u0600-\u06FF] is Arabic character. So,you could refer to below demo only math Arabic and English characters.Just like this:

    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="only Arabic and  English" ControlToValidate="TextBox1" ValidationExpression="^(?:[a-zA-Z\s@,=%$#&_\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDCF\uFDF0-\uFDFF\uFE70-\uFEFF]|(?:\uD802[\uDE60-\uDE9F]|\uD83B[\uDE00-\uDEFF])){0,}$"></asp:RegularExpressionValidator>
    

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 20, 2021 2:49 AM

All replies

  • User1535942433 posted

    Hi aktham85,

    As far as I think,[a-zA-Z] is English character and [u0600-\u06FF] is Arabic character. So,you could refer to below demo only math Arabic and English characters.Just like this:

    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="only Arabic and  English" ControlToValidate="TextBox1" ValidationExpression="^(?:[a-zA-Z\s@,=%$#&_\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDCF\uFDF0-\uFDFF\uFE70-\uFEFF]|(?:\uD802[\uDE60-\uDE9F]|\uD83B[\uDE00-\uDEFF])){0,}$"></asp:RegularExpressionValidator>
    

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 20, 2021 2:49 AM
  • User-1665696529 posted

    Many thanks

    Tuesday, April 20, 2021 10:16 AM