DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Flex Regex Versus Java Regex + Howto Embed Regex In Flex
// Only allow 6 to 9 digits (and no more)
Flex: ^\d{6,9}$Java:
\\d{6,9}
Following code will NOT function as desired (the {} are interpreted as binding markers, thus not part of the regex):
<mx:RegExpValidator id="regExpValidator"
source="{te_value}"
property="text"
expression="^\d{6,9}$"
required="true"
flags="g"
trigger="{te_value}"
triggerEvent="change"/>
Following code will function as desired:
<mx:Script> ..
public var regex:String = "^\\d{6,9}$";
..
<mx:RegExpValidator id="regExpValidator"
source="{te_value}"
property="text"
expression="{regex}"
required="true"
flags="g"
trigger="{te_value}"
triggerEvent="change"/>





