• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Regex problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
nithin kamath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
nithin kamath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks... ..i probably missed the ^ last time...

regards
nithin
 
    Bookmark Topic Watch Topic
  • New Topic