|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need one Regular Expressioni'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 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 > 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.+)$" spamsickle@gmail.com wrote:
> Try something like: "^([\w+]) ([\w+]) (.+)$" Yes, of course. My oversight.> > 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, Yes, that's a bit more flexible. Except perhaps the \w in the third > something more like this should work: > > "^(\[.+\])\s*(\[.+\])\s*(\w.+)$" > group. That means that the first character has to be one of A-Za-z_0-9. "^(\[.+\])\s*(\[.+\])\s*(.+)$"
updatecommand
Design Question for Factory Pattern and Casting Types to read a textfile regarding his format Storing collection of one class inside another Session variable as string (array) Floating Menu Bar code convertor in VB.NET Express Edition using MDIList in a MDI form Access MDI child properties generically word automation bookmarks |
|||||||||||||||||||||||