This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing a string with non-whitespace leading and trailing characters

 
Salman Ahmed
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using J2SE 1.5, and am wondering what's the best way to parse a string from a line that has the following format:

[some-text-here]

I need to remove the leading "[" and trailing "]" characters and get just the "some-text-here" string.

Thanks.
 
Steve Luke
Bartender
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A simple regex for this would be:


You could run it like this:


It doesn't help with complex matching like brackets inside brackets... but it is a start.
 
Salman Ahmed
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve,

this is precisely what I was looking for - thanks!

Regards,


Salman Ahmed
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic