• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regex problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
nithin kamath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
nithin kamath
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks... ..i probably missed the ^ last time...

regards
nithin
 
reply
    Bookmark Topic Watch Topic
  • New Topic