Strip(i.e. remove) special character(s)


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* Strip(remove) special character(s) from a string.
  2.   Parameters -1-: String to process
  3.   -2-: Special character to strip
  4.   Note: If second parameter is null then the following list is used:
  5.   <tab>, <single quote>, <double quote>, <\>, <|>, <`>, <~>, <^>
  6. */
  7. FUNCTION strip_spc_character ( in_string IN varchar2,
  8. in_chars IN varchar2 DEFAULT NULL )
  9. RETURN varchar2
  10. IS
  11. tab CHAR( 1 ) := chr(9);
  12. double_quote CHAR( 1 ) := chr(34);
  13. single_quote CHAR( 1 ) := chr(39);
  14. mask varchar2( 80 ) := '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  15. v_special_chars varchar2( 80 ) := '`~^\|'||double_quote||single_quote||tab;
  16. BEGIN
  17. IF in_chars IS NOT NULL THEN
  18. v_special_chars := in_chars;
  19. END IF;
  20. RETURN translate( in_string, mask || v_special_chars, mask );
  21. exception
  22. WHEN others THEN
  23. RETURN in_string;
  24. END strip_spc_character;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.