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


[Flashcoders] RegExp Help

2011-03-11 Thread Karim Beyrouti
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