General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 16th, 2004, 02:53 PM
hammerman hammerman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 9 hammerman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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...

Reply With Quote
  #2  
Old January 16th, 2004, 02:55 PM
hammerman hammerman is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 9 hammerman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Opps.. sorry wrong forum!! my apologies..

sorry.

Reply With Quote
  #3  
Old January 16th, 2004, 04:41 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
\[(.*)\]

That should work. With matches, the first match being the text inside of [ and ]
__________________
ExoHelpDesk
ExoCrew Free Services

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Regular Expression Not Quite Correct


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT