Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Replacing strings like %3C with any functions in java

 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any function in JAva that i can use
to replace
%3C with <
%/*%3C with <
%3E with >
%2F with /
%0D%0A with
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nope but you can always build your own method for that purpose.
Have a look at the class Matcher in java.util.regex (J2SDK 1.4b2) which contains a method named replaceAll(). You could invoke replaceAll on the Pattern containing those weird character sequences you would like to replace.
You have to represent the character sequences you would like to replace with regular expression (the API contains a good doc about how to do it)...
HIH
 
Horaci Macias
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems as you wanted to url-decode Strings....I would have a look at java.net.URLDecoder and java.net.URLEncoder.
Sorry for the question but... what has your question to do with Programmer Certification Study ?
Hope it helps,
Horaci Macias
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic