javeiga-iest opened a new issue #1102:
URL: https://github.com/apache/royale-asjs/issues/1102


   Hi Guys, I am using RegEx class to use patterns in my project as i used to 
do in flex.
   
   I have seen that this class is already used in beads as "Restriction" of the 
TextInput in Jewel.
   
   I have discovered several pattern transformation problems when declaring a 
regular expression.
   
   Some context, i have that pattern i use to restrict text to hours and 
minutes:
   
   /^(\ *)([+\-]?)(\ *)(\d+)(\:|\.|\ )([0-5]{1})([0-9]{1})(\ *)$/gi
   
   I use that page to check my patterns: https://regexr.com/ As you can see, my 
pattern works fine.
   
![image](https://user-images.githubusercontent.com/55754204/114692822-44444480-9d19-11eb-9ff0-f1afd3f042c1.png)
   
   The problems come when we try to initialize a variable of type RegExp:
   
   **First issue**
   `var miexc2:RegExp=/^(\ *)([+\-]?)(\ *)(\d+)(\:|\.|\ )([0-5]{1})([0-9]{1})(\ 
*)$/gi;`
   
   The resulting mapping is as follows:
   
`/^(\\u0020*)([+\-]?)(\\u0020*)(\d+)(\:|\.|\\u0020)([0-5]{1})([0-9]{1})(\\u0020*)$/gi`
   When converting space to unicode it ignores the previous escape (\) and 
escapes twice. 
   The result should be:
   
`^(\u0020*)([+\-]?)(\u0020*)(\d+)(\:|\.|\u0020)([0-5]{1})([0-9]{1})(\u0020*)$/gi`
   
   **Seccond issue**
   
   Using the same regular expression, if instead of declaring it directly I do 
it through the constructor, passing it the pattern as a text string, the result 
is different.
   
   `var miexc3:RegExp=new RegExp("^(\ *)([+\-]?)(\ *)(\d+)(\:|\.|\ 
)([0-5]{1})([0-9]{1})(\ *)$","gi");`
   
   Result:
   
   `/^( *)([+-]?)( *)(d+)(:|.| )([0-5]{1})([0-9]{1})( *)$/gi/`
   
   
   What happened here? It seems that here it does respect the space character, 
however, it has not been able to respect the digit character (\d) removing the 
backslash character
   
   What was expected:
   `/^( *)([+-]?)( *)(\d+)(:|.| )([0-5]{1})([0-9]{1})( *)$/gi/`
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to