Hi Michael,
Firstly, I'm not quite sure your expression is right - it says g
_or_ 1 or 2 or 3 as the first character, whereas your sample starts
with a g then a 1.
But anyway - what you need to do is to test for the beginning and
end of the string. In regular expressions, you do this with the ^ and
the $ character.
You can also collapse down your expression to something a bit tighter.
This works (with the sample strings you gave):
^g(1|2|3)(e|w)\d{3}(-\d{2})?$
Which basically says match if:
The first character in the string is a g.
That's followed by a 1, 2 or 3.
Then a lower-case e or w (you could use (e|w|E|W) if you want to
handle uppercase too).
Then 3 digits
Then, possibly, a dash followed by two more digits.
Then the end of the string.
If any of that is false, the match won't happen.
By the way, a really good way to put together and test Regular
Expressions is to use Grant Skinner's online tool RegExr:
http://www.gskinner.com/RegExr/
Hope that helps (and gives you the results you want!)
Ian
On Thu, Nov 5, 2009 at 8:23 PM, Mendelsohn, Michael
<[email protected]> wrote:
> Hi list...
>
> I have some input text box with a go button that is enabled or disabled based
> on an Event.CHANGE for the TextInput. As someone types in a string, a go
> button becomes enabled or disabled, but I want the *entire* text in the text
> box to be considered, not just a matched substring. Is this possible?
>
> ((TextField(e.target).text).match(/(((g|1|2|3)(E|W)\d{3})|((g|1|2|3)(E|W)\d{3}-?(\d{2})?))/i))?activateGoButton(true):activateGoButton(false);
> For instance, the above code would enable the go button when you type the
> text: "g1e222-" But, it shouldn't at that point, because it should be
> expeciting two more numbers. Any tips are appreciated.
>
> Thanks,
> - Michael M.
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders