Home All Groups Group Topic Archive Search About

Need one Regular Expression

Author
14 May 2006 1:23 PM
Lucky
hi guys,
i'm practising regular expression. i've got one string and i want it to
split in groups.
i was trying to make one regular expression but i didn't successed.
please help me guys.

i'm using .NET 2.0's Regular expression class.

here is the string.

[Bulk] [symbiancollection] Free English & Indian Movies  36 China Town,
Gangster , Mission impossible 3


i need this output:

group 1 : [Bulk]
group 2 : [symbiancollection]
group 3 : Free English & Indian Movies  36 China Town, Gangster ,
Mission impossible 3

please,please guys help me out with this regular expression. i've found
it interesting but it seems hard to learn this thing.

thanks,
Lucky

Author
14 May 2006 5:45 PM
Göran_Andersson
Try something like: "^([\w+]) ([\w+]) (.+)$"

Lucky wrote:
Show quoteHide quote
> hi guys,
> i'm practising regular expression. i've got one string and i want it to
> split in groups.
> i was trying to make one regular expression but i didn't successed.
> please help me guys.
>
> i'm using .NET 2.0's Regular expression class.
>
> here is the string.
>
> [Bulk] [symbiancollection] Free English & Indian Movies  36 China Town,
> Gangster , Mission impossible 3
>
>
> i need this output:
>
> group 1 : [Bulk]
> group 2 : [symbiancollection]
> group 3 : Free English & Indian Movies  36 China Town, Gangster ,
> Mission impossible 3
>
> please,please guys help me out with this regular expression. i've found
> it interesting but it seems hard to learn this thing.
>
> thanks,
> Lucky
>
Author
15 May 2006 4:51 AM
spamsickle
Try something like: "^([\w+]) ([\w+]) (.+)$"

I think you need to escape the square brackets, otherwise they're
interpreted as a character set.

If Group 1 and Group 2 are consistently between square brackets,
something more like this should work:

"^(\[.+\])\s*(\[.+\])\s*(\w.+)$"
Author
15 May 2006 7:26 AM
Göran_Andersson
spamsickle@gmail.com wrote:
> Try something like: "^([\w+]) ([\w+]) (.+)$"
>
> I think you need to escape the square brackets, otherwise they're
> interpreted as a character set.

Yes, of course. My oversight.

> If Group 1 and Group 2 are consistently between square brackets,
> something more like this should work:
>
> "^(\[.+\])\s*(\[.+\])\s*(\w.+)$"
>

Yes, that's a bit more flexible. Except perhaps the \w in the third
group. That means that the first character has to be one of A-Za-z_0-9.

"^(\[.+\])\s*(\[.+\])\s*(.+)$"