Re: [Flashcoders] RegExp Help

2011-03-13 Thread Karim Beyrouti
I seem to be having some mixed results with this one:

var tStr: String = '-path:c:\test path\temp -param spaced string -x'
var patt: RegExp = new RegExp( 
'(?<=[-{1,2}|/])(?P[a-zA-Z0-9]*)(?::|=)*(?P[\w|.|?|=|&|+| 
|:|/|\\]*)(?=[ |"]|$)' , 'g');
var result  : Object = patt.exec(tStr );

As it currently stands - it's not picking up P properly. it seems to be 
working in Grants RegExp tool. But am having issues picking up the groups in my 
code. 
This is my first attempt with RegExp, I guess it's not the easiest start. 
Maybe it would be better to write a parser for this one, but am curious to know 
if it can be done with AS3 RegExp.

Cheers


Karim 

On 13 Mar 2011, at 09:27, Karim Beyrouti wrote:

> This is great - thanks for explaining, helps a lot.
> 
> the original expression I posted works this tool : http://gskinner.com/RegExr
> I would love to know what magic Grant is using to get it working in his 
> RegExp utility. 
> 
> 
> Thank you Anthony.
> 
> 
> On 11 Mar 2011, at 23:42, Anthony Pace wrote:
> 
>> Hi Karim and Ktu,
>> 
>> Below is an explanation of what appears to be going on in the given pattern:
>> 
>> (?:\s*)
>> is a greedy non-capturing group of whitespace
>> 
>> (?<=[-|/])
>> is looking behind the next section of the expression, (?\w*),
>> for, what is in this case, a character set; as well, it does so
>> without including it in the result.  In this case the character
>> set could also be written without the |, resulting in [-/]
>> 
>> (?\w*)
>> is looking for name>\w*, before the next expression [:|=]
>> you may have wanted (?P\w*)
>> 
>> [:|=]
>> is a character set  : or =, but again does not need the |,
>> and could be [:=] or something like (?::|=)
>> 
>> ("((?.*?)(?[\w]*))
>> is what I think you may have wanted to be an alternation,
>> and in another language it would have worked; however, not in AS3.
>> 
>> Apparently in AS3 in order to distinguish the syntax from a
>> lookbehind ?<  you need to use the syntax ?P
>> when defining a named group; as well, it is due to the fact that,
>> as far as I know, in AS3 you cannot use names of the same group
>> even a logical OR alternation.
>> 
>> 
>> On 3/11/2011 2:37 PM, Ktu wrote:
>>> I just plugged it into RegExr  and I can't make sense
>>> of it.
>>> 
>>> Try using that tool to build it. It really helps
>>> 
>>> 
>>> On Fri, Mar 11, 2011 at 5:56 AM, Karim Beyrouti  wrote:
>>> 
 Hello lovely list...I am trying to run a RegExp pattern on a String, and am
 not too sure why it's not working, and am not too sure why.
 Here is the code:
 
 var tStr: String= '/a:"value" -big="this" -test:123
 -test2=th_3'
 var r   : RegExp= new RegExp(
 '(?:\s*)(?<=[-|/])(?\w*)[:|=]("((?.*?)(?[\w]*))');
 var result  : Object= r.exec( str );
 
 result returns null... Maybe you can shed some light on what i am doing
 wrong here?
 
 Thanks...
 
 
 Karim
 
 ___
 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 Help

2011-03-13 Thread Karim Beyrouti
This is great - thanks for explaining, helps a lot.

the original expression I posted works this tool : http://gskinner.com/RegExr
I would love to know what magic Grant is using to get it working in his RegExp 
utility. 


Thank you Anthony.


On 11 Mar 2011, at 23:42, Anthony Pace wrote:

> Hi Karim and Ktu,
> 
> Below is an explanation of what appears to be going on in the given pattern:
> 
> (?:\s*)
> is a greedy non-capturing group of whitespace
> 
> (?<=[-|/])
> is looking behind the next section of the expression, (?\w*),
> for, what is in this case, a character set; as well, it does so
> without including it in the result.  In this case the character
> set could also be written without the |, resulting in [-/]
> 
> (?\w*)
> is looking for name>\w*, before the next expression [:|=]
> you may have wanted (?P\w*)
> 
> [:|=]
> is a character set  : or =, but again does not need the |,
> and could be [:=] or something like (?::|=)
> 
> ("((?.*?)(?[\w]*))
> is what I think you may have wanted to be an alternation,
> and in another language it would have worked; however, not in AS3.
> 
> Apparently in AS3 in order to distinguish the syntax from a
> lookbehind ?<  you need to use the syntax ?P
> when defining a named group; as well, it is due to the fact that,
> as far as I know, in AS3 you cannot use names of the same group
> even a logical OR alternation.
> 
> 
> On 3/11/2011 2:37 PM, Ktu wrote:
>> I just plugged it into RegExr  and I can't make sense
>> of it.
>> 
>> Try using that tool to build it. It really helps
>> 
>> 
>> On Fri, Mar 11, 2011 at 5:56 AM, Karim Beyrouti  wrote:
>> 
>>> Hello lovely list...I am trying to run a RegExp pattern on a String, and am
>>> not too sure why it's not working, and am not too sure why.
>>> Here is the code:
>>> 
>>> var tStr: String= '/a:"value" -big="this" -test:123
>>> -test2=th_3'
>>> var r   : RegExp= new RegExp(
>>> '(?:\s*)(?<=[-|/])(?\w*)[:|=]("((?.*?)(?[\w]*))');
>>> var result  : Object= r.exec( str );
>>> 
>>> result returns null... Maybe you can shed some light on what i am doing
>>> wrong here?
>>> 
>>> Thanks...
>>> 
>>> 
>>> Karim
>>> 
>>> ___
>>> 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 Help

2011-03-11 Thread Anthony Pace

Hi Karim and Ktu,

Below is an explanation of what appears to be going on in the given pattern:

(?:\s*)
is a greedy non-capturing group of whitespace

(?<=[-|/])
is looking behind the next section of the expression, (?\w*),
for, what is in this case, a character set; as well, it does so
without including it in the result.  In this case the character
set could also be written without the |, resulting in [-/]

(?\w*)
is looking for name>\w*, before the next expression [:|=]
you may have wanted (?P\w*)

[:|=]
is a character set  : or =, but again does not need the |,
and could be [:=] or something like (?::|=)

("((?.*?)(?[\w]*))
is what I think you may have wanted to be an alternation,
and in another language it would have worked; however, not in AS3.

Apparently in AS3 in order to distinguish the syntax from a
lookbehind ?<  you need to use the syntax ?P
when defining a named group; as well, it is due to the fact that,
as far as I know, in AS3 you cannot use names of the same group
even a logical OR alternation.


On 3/11/2011 2:37 PM, Ktu wrote:

I just plugged it into RegExr  and I can't make sense
of it.

Try using that tool to build it. It really helps


On Fri, Mar 11, 2011 at 5:56 AM, Karim Beyrouti  wrote:


Hello lovely list...I am trying to run a RegExp pattern on a String, and am
not too sure why it's not working, and am not too sure why.
Here is the code:

var tStr: String= '/a:"value" -big="this" -test:123
-test2=th_3'
var r   : RegExp= new RegExp(
'(?:\s*)(?<=[-|/])(?\w*)[:|=]("((?.*?)(?[\w]*))');
var result  : Object= r.exec( str );

result returns null... Maybe you can shed some light on what i am doing
wrong here?

Thanks...


Karim

___
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 Help

2011-03-11 Thread Ktu
I just plugged it into RegExr  and I can't make sense
of it.

Try using that tool to build it. It really helps


On Fri, Mar 11, 2011 at 5:56 AM, Karim Beyrouti  wrote:

> Hello lovely list...I am trying to run a RegExp pattern on a String, and am
> not too sure why it's not working, and am not too sure why.
> Here is the code:
>
> var tStr: String= '/a:"value" -big="this" -test:123
> -test2=th_3'
> var r   : RegExp= new RegExp(
> '(?:\s*)(?<=[-|/])(?\w*)[:|=]("((?.*?)(?[\w]*))');
> var result  : Object= r.exec( str );
>
> result returns null... Maybe you can shed some light on what i am doing
> wrong here?
>
> Thanks...
>
>
> Karim
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
Ktu;

The information contained in this message may be privileged and/or
confidential. If you are NOT the intended recipient, please notify the
sender immediately and destroy this message.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] regExp

2010-06-18 Thread Karl DeSaulniers

Looks like it worked.
Tried a dozen OCR sites and none could match any letters.
There may be a super OCR bot somewhere, but not really worried.

Anyone know of somewhere I can test further, similar to what the bots  
use?

I figure this question may have a taboo answer, just want to be sure.


Karl

On Jun 18, 2010, at 2:51 AM, Karl DeSaulniers wrote:


Ah, yes, I thought I has stated that. I am using AS2.
I tried setting the Math.random first and then I used Math.floor,  
that seemed to work,

but I put an extra catch and set up a..

if(ranCode == undefined){
ranCode = 0;
}

and so a zero gets added instead of any undefined
and that seems to suffice. I just hope I never get all undefined 
(s). lol all zeros

But all in all i got it to work and not done refining.

I was creating my own captcha and it works. Now I just need to test  
if the characters are recognizable by a reader.

Onward and upward. :)
Thanks everyone for your help.. it helped a lot.

Karl


On Jun 18, 2010, at 1:25 AM, Steven Sacks wrote:

I guess you were using AS2? There is no native RegEx in AS2,  
though, so I don't see how you were going to use AS3 in AS2. In  
AS3, you should NEVER use anything other than ints to iterate  
integer values. Don't use uint, and don't use Number.


That code I provided is code I wrote and tested in Flash, not in  
the email. That being said, it should have been:


int(Math.random() * 62)

not

Math.round(Math.random() * 62)

Since array[array.length] will return undefined.



On 6/17/2010 12:45 PM, Karl DeSaulniers wrote:

Thanks Juan, Thanks Jim.

@Steve
I noticed with your example I get "undefined" as one of the results.
Also, I had to change the var i:int; to var i:number = 0;
I got an error with int saying it could not load the class or  
interface

for int.
What am I missing here?
TIA

Karl

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


Karl DeSaulniers
Design Drumm
http://designdrumm.com

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


Karl DeSaulniers
Design Drumm
http://designdrumm.com

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


Re: [Flashcoders] regExp

2010-06-18 Thread Karl DeSaulniers

Ah, yes, I thought I has stated that. I am using AS2.
I tried setting the Math.random first and then I used Math.floor,  
that seemed to work,

but I put an extra catch and set up a..

if(ranCode == undefined){
ranCode = 0;
}

and so a zero gets added instead of any undefined
and that seems to suffice. I just hope I never get all undefined(s).  
lol all zeros

But all in all i got it to work and not done refining.

I was creating my own captcha and it works. Now I just need to test  
if the characters are recognizable by a reader.

Onward and upward. :)
Thanks everyone for your help.. it helped a lot.

Karl


On Jun 18, 2010, at 1:25 AM, Steven Sacks wrote:

I guess you were using AS2? There is no native RegEx in AS2,  
though, so I don't see how you were going to use AS3 in AS2. In  
AS3, you should NEVER use anything other than ints to iterate  
integer values. Don't use uint, and don't use Number.


That code I provided is code I wrote and tested in Flash, not in  
the email. That being said, it should have been:


int(Math.random() * 62)

not

Math.round(Math.random() * 62)

Since array[array.length] will return undefined.



On 6/17/2010 12:45 PM, Karl DeSaulniers wrote:

Thanks Juan, Thanks Jim.

@Steve
I noticed with your example I get "undefined" as one of the results.
Also, I had to change the var i:int; to var i:number = 0;
I got an error with int saying it could not load the class or  
interface

for int.
What am I missing here?
TIA

Karl

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


Karl DeSaulniers
Design Drumm
http://designdrumm.com

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


Re: [Flashcoders] regExp

2010-06-18 Thread Steven Sacks
And just to add to this, in AS3, I never use Array anymore for the very reason 
that passing an out of range value returns undefined instead of throwing an out 
of range error. So, I always use Vector.

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


Re: [Flashcoders] regExp

2010-06-17 Thread Steven Sacks
I guess you were using AS2? There is no native RegEx in AS2, though, so I don't 
see how you were going to use AS3 in AS2. In AS3, you should NEVER use anything 
other than ints to iterate integer values. Don't use uint, and don't use Number.


That code I provided is code I wrote and tested in Flash, not in the email. That 
being said, it should have been:


int(Math.random() * 62)

not

Math.round(Math.random() * 62)

Since array[array.length] will return undefined.



On 6/17/2010 12:45 PM, Karl DeSaulniers wrote:

Thanks Juan, Thanks Jim.

@Steve
I noticed with your example I get "undefined" as one of the results.
Also, I had to change the var i:int; to var i:number = 0;
I got an error with int saying it could not load the class or interface
for int.
What am I missing here?
TIA

Karl

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


Re: [Flashcoders] regExp

2010-06-17 Thread Karl DeSaulniers

Thanks Juan, Thanks Jim.

@Steve
I noticed with your example I get "undefined" as one of the results.
Also, I had to change the var i:int; to var i:number = 0;
I got an error with int saying it could not load the class or  
interface for int.

What am I missing here?
TIA

Karl


On Jun 17, 2010, at 9:28 AM, Juan Pablo Califano wrote:

If don't want to learn the ascii codes by heart (or look them up),  
you can

use charCodeAt() like this:

var first:int = ("A").charCodeAt(0);
var last:int = ("Z").charCodeAt(0);

for (var i:int = first; i <= last; i++) {
 trace(String.fromCharCode(i));
}

Cheers
Juan Pablo Califano
2010/6/17 Karl DeSaulniers 


Ah thanks Steve.
So is 97 to 123 the placement of upper and lowercase letters and the
numbers on the CharCode chart?
and are the upper and lowercase letters 32 letters apart on the  
chart?
Trying to understand where you got these values. Your solution is  
very good

and interesting to me.
Also, why random off of 62? Is that the total characters in the array
alphaNumeric?
Thank you for this.

Karl



On Jun 17, 2010, at 12:57 AM, Steven Sacks wrote:

RegEx isn't really used for what you're talking about.


You should use ascii codes to create your alphanumeric array and  
then

choose random indexes from  it to create your random string.

var i:int;
var alphaNumeric:Array = [];
for (i = 97; i < 123; ++i)
{
   alphaNumeric.push(String.fromCharCode(i));
   alphaNumeric.push(String.fromCharCode(i - 32));
}
for (i = 0; i < 10; ++i)
{
   alphaNumeric.push(i);
}
function getRandomString(i:int):String
{
   var str:String = "";
   while (i--)
   {
   str += alphaNumeric[Math.round(Math.random() * 62)];
   }
   return str;
}

trace(getRandomString(8));
-- lKzU4e0X

It's worth pointing out that Math.random() is merely decent at  
generating

random values. If you really need random values, it is better to use
something like the Parker Miller pseudo-random number generator.

http://www.gskinner.com/blog/archives/2008/01/source_code_see.html
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



Karl DeSaulniers
Design Drumm
http://designdrumm.com

___
 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


Karl DeSaulniers
Design Drumm
http://designdrumm.com

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


Re: [Flashcoders] regExp

2010-06-17 Thread Juan Pablo Califano
If don't want to learn the ascii codes by heart (or look them up), you can
use charCodeAt() like this:

var first:int = ("A").charCodeAt(0);
var last:int = ("Z").charCodeAt(0);

for (var i:int = first; i <= last; i++) {
 trace(String.fromCharCode(i));
}

Cheers
Juan Pablo Califano
2010/6/17 Karl DeSaulniers 

> Ah thanks Steve.
> So is 97 to 123 the placement of upper and lowercase letters and the
> numbers on the CharCode chart?
> and are the upper and lowercase letters 32 letters apart on the chart?
> Trying to understand where you got these values. Your solution is very good
> and interesting to me.
> Also, why random off of 62? Is that the total characters in the array
> alphaNumeric?
> Thank you for this.
>
> Karl
>
>
>
> On Jun 17, 2010, at 12:57 AM, Steven Sacks wrote:
>
> RegEx isn't really used for what you're talking about.
>>
>> You should use ascii codes to create your alphanumeric array and then
>> choose random indexes from  it to create your random string.
>>
>> var i:int;
>> var alphaNumeric:Array = [];
>> for (i = 97; i < 123; ++i)
>> {
>>alphaNumeric.push(String.fromCharCode(i));
>>alphaNumeric.push(String.fromCharCode(i - 32));
>> }
>> for (i = 0; i < 10; ++i)
>> {
>>alphaNumeric.push(i);
>> }
>> function getRandomString(i:int):String
>> {
>>var str:String = "";
>>while (i--)
>>{
>>str += alphaNumeric[Math.round(Math.random() * 62)];
>>}
>>return str;
>> }
>>
>> trace(getRandomString(8));
>> -- lKzU4e0X
>>
>> It's worth pointing out that Math.random() is merely decent at generating
>> random values. If you really need random values, it is better to use
>> something like the Parker Miller pseudo-random number generator.
>>
>> http://www.gskinner.com/blog/archives/2008/01/source_code_see.html
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
> ___
>  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

2010-06-17 Thread Jim Lafser
In hexadecimal representation:
A = 0x41, a = 0x61 ...
All lowercase letters = uppercase + 0x20
0x20 = 32.




From: Karl DeSaulniers 
To: Flash Coders List 
Sent: Thu, June 17, 2010 3:56:17 AM
Subject: Re: [Flashcoders] regExp

Nice! Thank you.


On Jun 17, 2010, at 2:49 AM, Steven Sacks wrote:

> http://www.asciitable.com/
> 
> a-z = 97-122
> A-Z = 65-90
> 
> 97 - 65 = 32
> 
> a-z = 26 letters
> A-Z = 26 letters
> 0-9 = 10 numbers
> 
> 26 + 26 + 10 = 62
> 
> 
> On 6/16/2010 11:15 PM, Karl DeSaulniers wrote:
>> Ah thanks Steve.
>> So is 97 to 123 the placement of upper and lowercase letters and the
>> numbers on the CharCode chart?
>> and are the upper and lowercase letters 32 letters apart on the chart?
>> Trying to understand where you got these values. Your solution is very
>> good and interesting to me.
>> Also, why random off of 62? Is that the total characters in the array
>> alphaNumeric?
>> Thank you for this.
>> 
>> Karl
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl DeSaulniers
Design Drumm
http://designdrumm.com

___
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

2010-06-17 Thread Karl DeSaulniers

Nice! Thank you.


On Jun 17, 2010, at 2:49 AM, Steven Sacks wrote:


http://www.asciitable.com/

a-z = 97-122
A-Z = 65-90

97 - 65 = 32

a-z = 26 letters
A-Z = 26 letters
0-9 = 10 numbers

26 + 26 + 10 = 62


On 6/16/2010 11:15 PM, Karl DeSaulniers wrote:

Ah thanks Steve.
So is 97 to 123 the placement of upper and lowercase letters and the
numbers on the CharCode chart?
and are the upper and lowercase letters 32 letters apart on the  
chart?
Trying to understand where you got these values. Your solution is  
very

good and interesting to me.
Also, why random off of 62? Is that the total characters in the array
alphaNumeric?
Thank you for this.

Karl

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


Karl DeSaulniers
Design Drumm
http://designdrumm.com

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


Re: [Flashcoders] regExp

2010-06-17 Thread Steven Sacks

http://www.asciitable.com/

a-z = 97-122
A-Z = 65-90

97 - 65 = 32

a-z = 26 letters
A-Z = 26 letters
0-9 = 10 numbers

26 + 26 + 10 = 62


On 6/16/2010 11:15 PM, Karl DeSaulniers wrote:

Ah thanks Steve.
So is 97 to 123 the placement of upper and lowercase letters and the
numbers on the CharCode chart?
and are the upper and lowercase letters 32 letters apart on the chart?
Trying to understand where you got these values. Your solution is very
good and interesting to me.
Also, why random off of 62? Is that the total characters in the array
alphaNumeric?
Thank you for this.

Karl

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


Re: [Flashcoders] regExp

2010-06-16 Thread Karl DeSaulniers

Ah thanks Steve.
So is 97 to 123 the placement of upper and lowercase letters and the  
numbers on the CharCode chart?

and are the upper and lowercase letters 32 letters apart on the chart?
Trying to understand where you got these values. Your solution is  
very good and interesting to me.
Also, why random off of 62? Is that the total characters in the array  
alphaNumeric?

Thank you for this.

Karl


On Jun 17, 2010, at 12:57 AM, Steven Sacks wrote:


RegEx isn't really used for what you're talking about.

You should use ascii codes to create your alphanumeric array and  
then choose random indexes from  it to create your random string.


var i:int;
var alphaNumeric:Array = [];
for (i = 97; i < 123; ++i)
{
alphaNumeric.push(String.fromCharCode(i));
alphaNumeric.push(String.fromCharCode(i - 32));
}
for (i = 0; i < 10; ++i)
{
alphaNumeric.push(i);
}
function getRandomString(i:int):String
{
var str:String = "";
while (i--)
{
str += alphaNumeric[Math.round(Math.random() * 62)];
}
return str;
}

trace(getRandomString(8));
-- lKzU4e0X

It's worth pointing out that Math.random() is merely decent at  
generating random values. If you really need random values, it is  
better to use something like the Parker Miller pseudo-random number  
generator.


http://www.gskinner.com/blog/archives/2008/01/source_code_see.html
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Karl DeSaulniers
Design Drumm
http://designdrumm.com

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


Re: [Flashcoders] regExp

2010-06-16 Thread Steven Sacks

RegEx isn't really used for what you're talking about.

You should use ascii codes to create your alphanumeric array and then choose 
random indexes from  it to create your random string.


var i:int;
var alphaNumeric:Array = [];
for (i = 97; i < 123; ++i)
{
alphaNumeric.push(String.fromCharCode(i));
alphaNumeric.push(String.fromCharCode(i - 32));
}
for (i = 0; i < 10; ++i)
{
alphaNumeric.push(i);
}
function getRandomString(i:int):String
{
var str:String = "";
while (i--)
{
str += alphaNumeric[Math.round(Math.random() * 62)];
}
return str;
}

trace(getRandomString(8));
-- lKzU4e0X

It's worth pointing out that Math.random() is merely decent at generating random 
values. If you really need random values, it is better to use something like the 
Parker Miller pseudo-random number generator.


http://www.gskinner.com/blog/archives/2008/01/source_code_see.html
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] RegExp

2010-03-12 Thread Mendelsohn, Michael
Here's a great RegEx resource:
http://gskinner.com/RegExr/

- MM

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


Re: [Flashcoders] RegExp

2010-03-12 Thread Karl DeSaulniers

Correction, this actually starts the pages.

http://lawrence.ecorp.net/inet/samples/regexp-intro.php

Enjoy!,
Thanks Lawrence ;)

Karl


On Mar 12, 2010, at 2:16 AM, Cor wrote:

Very nice!

Thanks Karl!

Regards
Cor van Dooren

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
DeSaulniers
Sent: vrijdag 12 maart 2010 8:36
To: Flash List
Subject: [Flashcoders] RegExp

Hello List,
A while back I remember someone asking about RegExp (regular
expressions).
I found this website. Now it is not flash based, it is javascript,
but interesting none the less.
May give people hints on how to construct their own in AS or even PHP
for that matter.
I am new to lists in general, so if this is bad form, let me know.
I just like sharing :) and thought this could help someone.

Best,

http://lawrence.ecorp.net/inet/samples/regexp-format.php

Karl DeSaulniers
Design Drumm
http://designdrumm.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.733 / Virus Database: 271.1.1/2739 - Release Date: 03/11/10
22:50:00

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

Karl DeSaulniers
Design Drumm
http://designdrumm.com

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


RE: [Flashcoders] RegExp

2010-03-12 Thread Cor
Very nice!

Thanks Karl!

Regards
Cor van Dooren

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
DeSaulniers
Sent: vrijdag 12 maart 2010 8:36
To: Flash List
Subject: [Flashcoders] RegExp

Hello List,
A while back I remember someone asking about RegExp (regular  
expressions).
I found this website. Now it is not flash based, it is javascript,  
but interesting none the less.
May give people hints on how to construct their own in AS or even PHP  
for that matter.
I am new to lists in general, so if this is bad form, let me know.
I just like sharing :) and thought this could help someone.

Best,

http://lawrence.ecorp.net/inet/samples/regexp-format.php

Karl DeSaulniers
Design Drumm
http://designdrumm.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 9.0.733 / Virus Database: 271.1.1/2739 - Release Date: 03/11/10
22:50:00

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


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 vs. CDATA in E4X

2009-09-15 Thread Mendelsohn, Michael
Will do, sage advice.

- MM 



> Write it the easy way. If it proves to be a bottleneck later, optimize it 
> then.


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


Re: [Flashcoders] RegExp vs. CDATA in E4X

2009-09-15 Thread Steven Sacks

You, sir, are a victim of premature optimization.

Write it the easy way. If it proves to be a bottleneck later, optimize it then.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] RegExp headache

2009-03-06 Thread Jiri

Everybody thank you!

Jiri

Merrill, Jason wrote:

Seriously, just play with RegExr / Regex Buddy, get the cheat sheets:


Am now - love it!  Can't I still be in awe?  :) 



Jason Merrill 


Bank of  America   |  Learning Performance Solutions Instructional
Technology & Media   
Learn about the Adobe Flash platform for rich media experiences - join
the Bank of America Flash Platform Community 


Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
personally, follow more nonsense on Facebook. 



___
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 headache

2009-03-05 Thread Merrill, Jason
>> Seriously, just play with RegExr / Regex Buddy, get the cheat sheets:

Am now - love it!  Can't I still be in awe?  :) 


Jason Merrill 

Bank of  America   |  Learning Performance Solutions Instructional
Technology & Media   
Learn about the Adobe Flash platform for rich media experiences - join
the Bank of America Flash Platform Community 

Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
personally, follow more nonsense on Facebook. 


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


Re: [Flashcoders] RegExp headache

2009-03-05 Thread Glen Pike

Seriously, just play with RegExr / Regex Buddy, get the cheat sheets:

http://www.regexbuddy.com/
http://gskinner.com/RegExr/

http://www.addedbytes.com/cheat-sheets/regular-expressions-cheat-sheet/

Then spend some time dealing with Apache & Mod Rewrite which will 
stretch your regex muscles...


http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/
http://www.addedbytes.com/apache/url-rewriting-for-beginners/

That's what I did, now one day I will be able to do the mental 
gymnastics of the other people, but for now, I will just have to keep 
looking up the RegEx bits - RegExr is good for this - because I have too 
many other things to learn along with RegEx's...


If you want to hurt your brain whilst learning them inside out try this:

http://www.regular-expressions.info/

Glen


Merrill, Jason wrote:

/(((<|>)=?)|==)?(-?\d+)/
hot darn.
  


A side note.  I'm so in awe at the people who understand and can write
Regular Expressions on a whim - I have hacked a few from some examples
for projects, but it's nothing I really understand too much, a skill I
need to learn - they are so handy.



Jason Merrill 


Bank of  America   |  Learning Performance Solutions Instructional
Technology & Media   
Learn about the Adobe Flash platform for rich media experiences - join
the Bank of America Flash Platform Community 


Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
personally, follow more nonsense on Facebook. 





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


  


--

Glen Pike
01326 218440
www.glenpike.co.uk 

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


RE: [Flashcoders] RegExp headache

2009-03-05 Thread Merrill, Jason
Cool - I just download the AIR version, installing it now and checking it out.


Jason Merrill 

Bank of  America   |  Learning Performance Solutions Instructional Technology & 
Media   
Learn about the Adobe Flash platform for rich media experiences - join the Bank 
of America Flash Platform Community 

Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me 
personally, follow more nonsense on Facebook. 






-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Ian Thomas
Sent: Thursday, March 05, 2009 1:58 PM
To: Flash Coders List
Subject: Re: [Flashcoders] RegExp headache

Like Glen said, check out Grant's RegExr - it really helps this kind
of thing out. :-)

Ian

On Thu, Mar 5, 2009 at 6:51 PM, Merrill, Jason
 wrote:
>>>/(((<|>)=?)|==)?(-?\d+)/
>>>hot darn.
>
> A side note.  I'm so in awe at the people who understand and can write
> Regular Expressions on a whim - I have hacked a few from some examples
> for projects, but it's nothing I really understand too much, a skill I
> need to learn - they are so handy.
>
>
> Jason Merrill
>
> Bank of  America   |  Learning Performance Solutions Instructional
> Technology & Media
> Learn about the Adobe Flash platform for rich media experiences - join
> the Bank of America Flash Platform Community
>
> Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
> personally, follow more nonsense on Facebook.
>
>
>
>
> ___
> 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 headache

2009-03-05 Thread Ian Thomas
Like Glen said, check out Grant's RegExr - it really helps this kind
of thing out. :-)

Ian

On Thu, Mar 5, 2009 at 6:51 PM, Merrill, Jason
 wrote:
>>>/(((<|>)=?)|==)?(-?\d+)/
>>>hot darn.
>
> A side note.  I'm so in awe at the people who understand and can write
> Regular Expressions on a whim - I have hacked a few from some examples
> for projects, but it's nothing I really understand too much, a skill I
> need to learn - they are so handy.
>
>
> Jason Merrill
>
> Bank of  America   |  Learning Performance Solutions Instructional
> Technology & Media
> Learn about the Adobe Flash platform for rich media experiences - join
> the Bank of America Flash Platform Community
>
> Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
> personally, follow more nonsense on Facebook.
>
>
>
>
> ___
> 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 headache

2009-03-05 Thread Merrill, Jason
>>/(((<|>)=?)|==)?(-?\d+)/
>>hot darn.

A side note.  I'm so in awe at the people who understand and can write
Regular Expressions on a whim - I have hacked a few from some examples
for projects, but it's nothing I really understand too much, a skill I
need to learn - they are so handy.


Jason Merrill 

Bank of  America   |  Learning Performance Solutions Instructional
Technology & Media   
Learn about the Adobe Flash platform for rich media experiences - join
the Bank of America Flash Platform Community 

Anyone can follow my nonsense on Twitter: jmerrill_2001.  If you know me
personally, follow more nonsense on Facebook. 




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


Re: [Flashcoders] RegExp headache

2009-03-05 Thread David Hershberger
oops, forgot about the comparison operator being optional.  New version:

/(((<|>)=?)|==)?(-?\d+)/

hot darn.
Dave

On Thu, Mar 5, 2009 at 10:44 AM, David Hershberger wrote:

> How's this?
>
> /(((<|>)=?)|==)(-?\d+)/
>
> Then the comparison operator is in result[1] and the number is in
> result[4].  You said "integer", so I threw in the optional negative sign. :)
>
> Dave
>
>
> On Thu, Mar 5, 2009 at 10:02 AM, Glen Pike wrote:
>
>> Hi,
>>
>>   How about:
>>
>>   /([=><]+)([0-9]+)/
>>
>>   Check out "RegExr" by Grant Skinner - it's lovely.
>>
>>   The problem with <= and >= is that there is "look behind" in the regex
>> controlled by these chars so the order of =>< seems to be important???
>> Glen
>>
>>
>> Jiri wrote:
>>
>>> I would like some help on a regExp
>>>
>>> I have a string and want to split it into the first character being a
>>> <|>|<=|>=|== the second part being an int.
>>>
>>> so ">100"
>>>
>>> would return
>>> result[1] = '>'
>>> result[2] = 100
>>>
>>> so "100"
>>>
>>> would return
>>> result[1] = 'undefined'
>>> result[2] = 100
>>>
>>> Here is what I have so far, but it is killing me.
>>>
>>>var pattern:RegExp = /^(\d)?(^\d+)|()/
>>>var result:Object = pattern.exec(tConditionalString);
>>>
>>> I tried another approach but i am still figuring out how to do it. It
>>> goes something like this
>>>var pattern:RegExp = /^(>):((?(2)then|else))
>>>
>>>
>>> Jiri
>>>
>>>
>>>
>>>
>>> ___
>>> 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 headache

2009-03-05 Thread David Hershberger
How's this?

/(((<|>)=?)|==)(-?\d+)/

Then the comparison operator is in result[1] and the number is in
result[4].  You said "integer", so I threw in the optional negative sign. :)

Dave

On Thu, Mar 5, 2009 at 10:02 AM, Glen Pike wrote:

> Hi,
>
>   How about:
>
>   /([=><]+)([0-9]+)/
>
>   Check out "RegExr" by Grant Skinner - it's lovely.
>
>   The problem with <= and >= is that there is "look behind" in the regex
> controlled by these chars so the order of =>< seems to be important???
> Glen
>
>
> Jiri wrote:
>
>> I would like some help on a regExp
>>
>> I have a string and want to split it into the first character being a
>> <|>|<=|>=|== the second part being an int.
>>
>> so ">100"
>>
>> would return
>> result[1] = '>'
>> result[2] = 100
>>
>> so "100"
>>
>> would return
>> result[1] = 'undefined'
>> result[2] = 100
>>
>> Here is what I have so far, but it is killing me.
>>
>>var pattern:RegExp = /^(\d)?(^\d+)|()/
>>var result:Object = pattern.exec(tConditionalString);
>>
>> I tried another approach but i am still figuring out how to do it. It goes
>> something like this
>>var pattern:RegExp = /^(>):((?(2)then|else))
>>
>>
>> Jiri
>>
>>
>>
>>
>> ___
>> 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 headache

2009-03-05 Thread Glen Pike

Hi,

   How about:

   /([=><]+)([0-9]+)/

   Check out "RegExr" by Grant Skinner - it's lovely.

   The problem with <= and >= is that there is "look behind" in the 
regex controlled by these chars so the order of =>< seems to be important???
  
   Glen


Jiri wrote:

I would like some help on a regExp

I have a string and want to split it into the first character being a 
<|>|<=|>=|== the second part being an int.


so ">100"

would return
result[1] = '>'
result[2] = 100

so "100"

would return
result[1] = 'undefined'
result[2] = 100

Here is what I have so far, but it is killing me.

var pattern:RegExp = /^(\d)?(^\d+)|()/
var result:Object = pattern.exec(tConditionalString);

I tried another approach but i am still figuring out how to do it. It 
goes something like this

var pattern:RegExp = /^(>):((?(2)then|else))


Jiri




___
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