
January 16th, 2004, 02:53 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 9
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Regular Expression Not Quite Correct
okay.. I'm not the best at writing reg exp so I'm sure this is simple but I've tried it a hundred different ways... Given a string I want to pull out the first occurance of all characters,digits,spaces and special chars between the [ and ]
for instance I usally have a string such as "[blah boo & foo] + [heeee]" I want to return "[blah boo & foo]" below is my feable attempt to get this...
I'm trying to use the below as my regex pattern...
\[.*\]
"\[.*\]" is somewhat sucessful.. but it returns the whole string (obviously because the string starts and ends with [ ]. So I try something like \[\w*\s*\] and that only works for something like [booo] no [boo foo]. I guess I'm stuck in the middle portion where I want everything between the [].. any help is much appreciated...
|