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, (?<name>\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 [-/]

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

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

("((?<value>.*?)(?<!\\)")|(?<value>[\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<desiredGroupName>
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<http://www.regexr.com>  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<[email protected]>  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*)(?<=[-|/])(?<name>\w*)[:|=]("((?<value>.*?)(?<!\\)")|(?<value>[\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
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders




_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to