RegEx expression help
-
I prefer the technique I showed. You then enumerate the Matches and fill a Dictionary with the Names and Values. Your requirements 1 -- 3 are then satisfied by the Dictionary and you only have to execute the RegEx once per group of properties.
Fayu wrote:
Use VBScript
Then why post it in the C# forum? Or maybe you should give more information on the bigger picture of what you are trying to accomplish.
Your solution will also give same result, but it will return all properties. As Fayu asked on his requirement, it wasnt he is looking for. Cheers !!!
-
Your solution will also give same result, but it will return all properties. As Fayu asked on his requirement, it wasnt he is looking for. Cheers !!!
Navnath R. Kale wrote:
it wasnt he is looking for
It should be.
-
I prefer the technique I showed. You then enumerate the Matches and fill a Dictionary with the Names and Values. Your requirements 1 -- 3 are then satisfied by the Dictionary and you only have to execute the RegEx once per group of properties.
Fayu wrote:
Use VBScript
Then why post it in the C# forum? Or maybe you should give more information on the bigger picture of what you are trying to accomplish.
Fayu wrote:
I wish I can use the CLR but the requirements I have prevent me from using the CLR.
::Throws up hands::
-
Fayu wrote:
I wish I can use the CLR but the requirements I have prevent me from using the CLR.
::Throws up hands::
-
Yea but I am not using the clr. The pattern he provided worked with all requirement, including not using CLR. I used his pattern using VBScript.RegexExp and it worked wonders. Thanks for your help as well.
Mine works with perl:
perl -e "print \"[[[MyProperty1]]] Value [[[MyProperty2]]] value2 [[[MyProperty3]]] value 3\" =~ m/(?:\[\[\[(?'Name'.*?)\]\]\](?'Value'[^\[]*))/g"
%stuff = $ARGV[0] =~ m/(?:\[\[\[(?'Name'.*?)\]\]\](?'Value'[^\[]*))/g ;
foreach $id ( sort ( keys ( %stuff ) ) )
{
print ( "$id = $stuff{$id}\n" ) ;
}modified on Saturday, April 10, 2010 12:33 AM
-
Mine works with perl:
perl -e "print \"[[[MyProperty1]]] Value [[[MyProperty2]]] value2 [[[MyProperty3]]] value 3\" =~ m/(?:\[\[\[(?'Name'.*?)\]\]\](?'Value'[^\[]*))/g"
%stuff = $ARGV[0] =~ m/(?:\[\[\[(?'Name'.*?)\]\]\](?'Value'[^\[]*))/g ;
foreach $id ( sort ( keys ( %stuff ) ) )
{
print ( "$id = $stuff{$id}\n" ) ;
}modified on Saturday, April 10, 2010 12:33 AM
Well i guess, all this confusion is because question is in wrong section. Perl supports Named capture groups but client scripts don't.
-
Well i guess, all this confusion is because question is in wrong section. Perl supports Named capture groups but client scripts don't.
Navnath R. Kale wrote:
Named capture groups
You don't need to name them. The important thing is to have the engine return all the matches and enumerate them.
-
Navnath R. Kale wrote:
Named capture groups
You don't need to name them. The important thing is to have the engine return all the matches and enumerate them.
:doh: !!! Now the thread becomes the session. Actually (?'Name') and (?'Value') is equal to (?<Name>) and (?<Value>) and is nothing but Named capturing group. .Net supports it both way.
-
:doh: !!! Now the thread becomes the session. Actually (?'Name') and (?'Value') is equal to (?<Name>) and (?<Value>) and is nothing but Named capturing group. .Net supports it both way.
Yes. I prefer the apostrophes -- at least I don't need to escape them when I post them. :-D
-
Yes. I prefer the apostrophes -- at least I don't need to escape them when I post them. :-D
Yeah :laugh: On first post I was like " :doh: WTF happened to my pattern, it was correct when I typed"