Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Parsing a string with non-whitespace leading and trailing characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parsing a string with non-whitespace leading and trailing characters" Watch "Parsing a string with non-whitespace leading and trailing characters" New topic
Author

Parsing a string with non-whitespace leading and trailing characters

Salman Ahmed
Greenhorn

Joined: Mar 18, 2008
Posts: 27
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

Joined: Jan 28, 2003
Posts: 4181
    
  21

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.


Steve
Salman Ahmed
Greenhorn

Joined: Mar 18, 2008
Posts: 27
Steve,

this is precisely what I was looking for - thanks!

Regards,


Salman Ahmed
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing a string with non-whitespace leading and trailing characters