wood burning stoves 2.0*
The moose likes Java in General and the fly likes Regex problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regex problem" Watch "Regex problem" New topic
Author

Regex problem

nithin kamath
Greenhorn

Joined: Aug 07, 2009
Posts: 3
Hi,
I have a string {abc.def}, I want to use a regular expression which replaces any non alphanumeric things at the begining and the end with an empty space. I have tried (^[^a-zA-Z0-9]) which removes the characters from the begining and this ([^a-zA-Z0-9]$) which removes it from the end, I would like to know how i can combine both of them. I have tried appending a .* in between which does not seem to work.

regards
nithin
krishna bala
Ranch Hand

Joined: Jul 20, 2009
Posts: 62
nithin kamath
Greenhorn

Joined: Aug 07, 2009
Posts: 3
The string which i am referring to is {abc.def}(with the braces). Specifically i want to remove anything that's not alphanumeric at the begininig or the end with an empty space. i.e in the example of {abc.def} replace it with abc.def. I tried the solution given above, it still prints {abc.def} if i use it.

Thanks and regards
nithin
krishna bala
Ranch Hand

Joined: Jul 20, 2009
Posts: 62
nithin kamath
Greenhorn

Joined: Aug 07, 2009
Posts: 3
Thanks... ..i probably missed the ^ last time...

regards
nithin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regex problem