RE: [Flashcoders] RegExp question

2009-11-05 Thread Mendelsohn, Michael
Thanks very much Ian and Henrik.  The ^ and $ was exactly what I was looking 
for.

Regards,
- Michael M.


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] RegExp question

2009-11-05 Thread Henrik Andersson

Mendelsohn, Michael wrote:

I want the *entire* text in the text box to be considered, not just a matched 
substring.  Is this possible?


Use ^ to lock to the begining of the string and $ to lock to the end of 
the string, use both and it will not be allowed anything other than the 
expression.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] RegExp question

2009-11-05 Thread Ian Thomas
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
 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
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-04 Thread Allandt Bik-Elliott (Receptacle)

wow - that's really helpful - thanks a lot for your time claudius

best
a


On 4 Jul 2008, at 14:56, Claudius Ceteras wrote:






the \b boundary worked a treat - i'm just researching why it
worked now



/(\d\d\d)(?=(?:\d\d\d)*\b)/g

Find all groups of three digits < (\d\d\d) >, which are followed by <
positive lookahead: (?= ) >
0, 3, 6, 9, ... Digits, followed by a word boundary < (?:\d\d\d)*\b >

Word boundaries match at the end of the number, so because it only  
matches

three digits groups which are followed by a number of digits which is
divisible by 3, it doesnt find "123" in "1234567", but  
"234" (because it's
followed by 3 digits followed by a word boundary) and  
"456" (because it's

followed by 0 digits followed by a wod boundary)

Btw,
(?:   ) is a non-capturing group,
(?=   ) is a positive lookahead.
You can google for both...


regards

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] regexp question

2008-07-04 Thread Claudius Ceteras


> 
> the \b boundary worked a treat - i'm just researching why it 
> worked now
> 

/(\d\d\d)(?=(?:\d\d\d)*\b)/g

Find all groups of three digits < (\d\d\d) >, which are followed by <
positive lookahead: (?= ) >
0, 3, 6, 9, ... Digits, followed by a word boundary < (?:\d\d\d)*\b >

Word boundaries match at the end of the number, so because it only matches
three digits groups which are followed by a number of digits which is
divisible by 3, it doesnt find "123" in "1234567", but "234" (because it's
followed by 3 digits followed by a word boundary) and "456" (because it's
followed by 0 digits followed by a wod boundary)

Btw,
(?:   ) is a non-capturing group,
(?=   ) is a positive lookahead.
You can google for both...


regards

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-04 Thread Allandt Bik-Elliott (Receptacle)

the \b boundary worked a treat - i'm just researching why it worked now

thanks for all your help guys

a


On 4 Jul 2008, at 13:17, Claudius Ceteras wrote:

To get this to also work with just the year you may replace [^\d]  
with

(?:[^\d]|$) which expects a non-digit or the end of the string


Or even better Replace [^\d] with \b which should also work.

regards

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] regexp question

2008-07-04 Thread Claudius Ceteras
> To get this to also work with just the year you may replace [^\d] with
> (?:[^\d]|$) which expects a non-digit or the end of the string

Or even better Replace [^\d] with \b which should also work.

regards

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] regexp question

2008-07-04 Thread Claudius Ceteras
Hi,

> var sYear:String = "1234567";
> var pattern:RegExp = /(\d\d\d)(?=(?:\d\d\d)*[^\d])/g;
> sYear = sYear.replace(pattern, ",$1");
> //traces 1234567

That's because [^\d] expects a non-digit after the number 

Try this:
var sYear:String = "The year when all happened was 1234567 indeed" // :)

To get this to also work with just the year you may replace [^\d] with
(?:[^\d]|$) which expects a non-digit or the end of the string


regards

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-04 Thread Allandt Bik-Elliott (Receptacle)

hey that's great sid - thanks

a


On 4 Jul 2008, at 12:26, Sidney de Koning wrote:


Hi Allandt,

Have you found this tool already? http://www.gskinner.com/blog/ 
archives/2008/03/regexr_free_onl.html

It allows you to test your regex pattern expecially for AS

And you can find a cheatsheat on RegEx on www.ilovejackdaniels.com  
and there is ofcourse alot on whttp://www.regular-expressions.info/ 
quickstart.html

and http://www.regular-expressions.info/tutorial.html

Hope this will get you started,

Sid

On Jul 4, 2008, at 11:32 AM, Allandt Bik-Elliott (Receptacle) wrote:


hi again

i've been trying different things and it seems that the [^0] or [^ 
\d] is stopping it working. (I needed to use $1 rather than \1 to  
reference the first group in the String.replace statement)


here is what i've got so far

var sYear:String = "1234567";
var pattern:RegExp = /(\d\d\d)(?=(?:\d\d\d)*[^\d])/g;
sYear = sYear.replace(pattern, ",$1");
//traces 1234567

if i drop the NOT part
var sYear:String = "1234567";
var pattern:RegExp = /(\d\d\d)(?=(?:\d\d\d)*)/g;
sYear = sYear.replace(pattern, ",$1");
//traces ,123,4567

This stuff is really new to me so i really appreciate the help

thanks
a

On 4 Jul 2008, at 01:09, Claudius Ceteras wrote:


Hi,


is there a way of counting back from the end of the number and
inserting the comma (even without a regular expression)? if i
use the
g modifier in the regexp (so var pattern:RegExp = /000/g;), it will
only pick up the first 000 (and every multiple thereafter)
instead of
leaving the first 0 (which is expected behaviour but something i'd
like to get around)


How about positive lookaheads?

/(000)(?=(?:000)*[^0])/g

If you want this also to work for "1234567" => "1,234,567", you  
can replace
every 0 in the pattern with \d and call the replace function with  
",\1"

instead of ",000"

This is untested, but should work... Let me know.

regards,

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-04 Thread Sidney de Koning

Hi Allandt,

Have you found this tool already? 
http://www.gskinner.com/blog/archives/2008/03/regexr_free_onl.html
It allows you to test your regex pattern expecially for AS

And you can find a cheatsheat on RegEx on www.ilovejackdaniels.com and  
there is ofcourse alot on whttp://www.regular-expressions.info/quickstart.html

and http://www.regular-expressions.info/tutorial.html

Hope this will get you started,

Sid

On Jul 4, 2008, at 11:32 AM, Allandt Bik-Elliott (Receptacle) wrote:


hi again

i've been trying different things and it seems that the [^0] or [^ 
\d] is stopping it working. (I needed to use $1 rather than \1 to  
reference the first group in the String.replace statement)


here is what i've got so far

var sYear:String = "1234567";
var pattern:RegExp = /(\d\d\d)(?=(?:\d\d\d)*[^\d])/g;
sYear = sYear.replace(pattern, ",$1");
//traces 1234567

if i drop the NOT part
var sYear:String = "1234567";
var pattern:RegExp = /(\d\d\d)(?=(?:\d\d\d)*)/g;
sYear = sYear.replace(pattern, ",$1");
//traces ,123,4567

This stuff is really new to me so i really appreciate the help

thanks
a

On 4 Jul 2008, at 01:09, Claudius Ceteras wrote:


Hi,


is there a way of counting back from the end of the number and
inserting the comma (even without a regular expression)? if i
use the
g modifier in the regexp (so var pattern:RegExp = /000/g;), it will
only pick up the first 000 (and every multiple thereafter)
instead of
leaving the first 0 (which is expected behaviour but something i'd
like to get around)


How about positive lookaheads?

/(000)(?=(?:000)*[^0])/g

If you want this also to work for "1234567" => "1,234,567", you can  
replace
every 0 in the pattern with \d and call the replace function with ", 
\1"

instead of ",000"

This is untested, but should work... Let me know.

regards,

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-04 Thread Allandt Bik-Elliott (Receptacle)

hi again

i've been trying different things and it seems that the [^0] or [^\d]  
is stopping it working. (I needed to use $1 rather than \1 to  
reference the first group in the String.replace statement)


here is what i've got so far

var sYear:String = "1234567";
var pattern:RegExp = /(\d\d\d)(?=(?:\d\d\d)*[^\d])/g;
sYear = sYear.replace(pattern, ",$1");
//traces 1234567

if i drop the NOT part
var sYear:String = "1234567";
var pattern:RegExp = /(\d\d\d)(?=(?:\d\d\d)*)/g;
sYear = sYear.replace(pattern, ",$1");
//traces ,123,4567

This stuff is really new to me so i really appreciate the help

thanks
a

On 4 Jul 2008, at 01:09, Claudius Ceteras wrote:


Hi,


is there a way of counting back from the end of the number and
inserting the comma (even without a regular expression)? if i
use the
g modifier in the regexp (so var pattern:RegExp = /000/g;), it will
only pick up the first 000 (and every multiple thereafter)
instead of
leaving the first 0 (which is expected behaviour but something i'd
like to get around)


How about positive lookaheads?

/(000)(?=(?:000)*[^0])/g

If you want this also to work for "1234567" => "1,234,567", you can  
replace
every 0 in the pattern with \d and call the replace function with ", 
\1"

instead of ",000"

This is untested, but should work... Let me know.

regards,

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-04 Thread Allandt Bik-Elliott (Receptacle)

wow - i have no idea what that means at all

time to hit the books - thanks :)

On 4 Jul 2008, at 01:09, Claudius Ceteras wrote:


Hi,


is there a way of counting back from the end of the number and
inserting the comma (even without a regular expression)? if i
use the
g modifier in the regexp (so var pattern:RegExp = /000/g;), it will
only pick up the first 000 (and every multiple thereafter)
instead of
leaving the first 0 (which is expected behaviour but something i'd
like to get around)


How about positive lookaheads?

/(000)(?=(?:000)*[^0])/g

If you want this also to work for "1234567" => "1,234,567", you can  
replace
every 0 in the pattern with \d and call the replace function with ", 
\1"

instead of ",000"

This is untested, but should work... Let me know.

regards,

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] regexp question

2008-07-03 Thread Claudius Ceteras
Hi,

> is there a way of counting back from the end of the number and  
> inserting the comma (even without a regular expression)? if i 
> use the  
> g modifier in the regexp (so var pattern:RegExp = /000/g;), it will  
> only pick up the first 000 (and every multiple thereafter) 
> instead of  
> leaving the first 0 (which is expected behaviour but something i'd  
> like to get around)

How about positive lookaheads?

/(000)(?=(?:000)*[^0])/g

If you want this also to work for "1234567" => "1,234,567", you can replace
every 0 in the pattern with \d and call the replace function with ",\1"
instead of ",000"

This is untested, but should work... Let me know.

regards,

Claudius

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-02 Thread Allandt Bik-Elliott (Receptacle)

thanks a lot :)


On 2 Jul 2008, at 15:24, Juan Pablo Califano wrote:


Hi,

You can check out ascb (ActionScript Cook Book), a library with  
some useful
functions. In this case, the class NumberFormat, and the method  
format may

do the job.

http://www.rightactionscript.com/ascb/

Almost any formatNumber method you can find in many other libraries  
will

help you too, except for some reason you want to roll your own.


Cheers
Juan Pablo Califano

2008/7/2, Allandt Bik-Elliott (Receptacle)  
<[EMAIL PROTECTED]>:


hey

i am using regexp to inject commas into my years by searching for  
000 and

replacing with ,000 like this

var pattern:RegExp = /000/;
sYear = sYear.replace(pattern, ",000");

however, this approach will bug every multiple of 10,000 as there  
are more

zeros than the pattern expects.

is there a way of counting back from the end of the number and  
inserting
the comma (even without a regular expression)? if i use the g  
modifier in
the regexp (so var pattern:RegExp = /000/g;), it will only pick up  
the first
000 (and every multiple thereafter) instead of leaving the first 0  
(which is

expected behaviour but something i'd like to get around)

would you use an if statement to count the length of the sYear  
string or is

there a better way?

at the moment, because i know that i only need years from 15,000  
bc, i'm

doing this:

   var sYear:String = String(nYear);
   if (sYear.length > 5)
   {
   if (sYear != "-1")
   {
   var pattern:RegExp = /000/;
   sYear = sYear.replace(pattern,
",000");
   } else {
   var pattern:RegExp = //;
   sYear = sYear.replace(pattern,
"0,000");
   }
   }

which is a bit hacky and limited

interested to hear your answer

a

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regexp question

2008-07-02 Thread Juan Pablo Califano
Hi,

You can check out ascb (ActionScript Cook Book), a library with some useful
functions. In this case, the class NumberFormat, and the method format may
do the job.

http://www.rightactionscript.com/ascb/

Almost any formatNumber method you can find in many other libraries will
help you too, except for some reason you want to roll your own.


Cheers
Juan Pablo Califano

2008/7/2, Allandt Bik-Elliott (Receptacle) <[EMAIL PROTECTED]>:
>
> hey
>
> i am using regexp to inject commas into my years by searching for 000 and
> replacing with ,000 like this
>
> var pattern:RegExp = /000/;
> sYear = sYear.replace(pattern, ",000");
>
> however, this approach will bug every multiple of 10,000 as there are more
> zeros than the pattern expects.
>
> is there a way of counting back from the end of the number and inserting
> the comma (even without a regular expression)? if i use the g modifier in
> the regexp (so var pattern:RegExp = /000/g;), it will only pick up the first
> 000 (and every multiple thereafter) instead of leaving the first 0 (which is
> expected behaviour but something i'd like to get around)
>
> would you use an if statement to count the length of the sYear string or is
> there a better way?
>
> at the moment, because i know that i only need years from 15,000 bc, i'm
> doing this:
>
>var sYear:String = String(nYear);
>if (sYear.length > 5)
>{
>if (sYear != "-1")
>{
>var pattern:RegExp = /000/;
>sYear = sYear.replace(pattern,
> ",000");
>} else {
>var pattern:RegExp = //;
>sYear = sYear.replace(pattern,
> "0,000");
>}
>}
>
> which is a bit hacky and limited
>
> interested to hear your answer
>
> a
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders