Replace unknown number of characters in a string with '*' in Oracle

replace character in string java
string to char array
string replace java
replace each character in a string with it's next letter in java
replace a character in a string c++
java replace character in string at index
replace a character in a string python
c program to replace a character in a string using recursion

Given a column MEMO_TXT has the following text in one MEMO table: 'Password changed from: 12345 to: abcdefg.'

How can i replace 12345 and abcdefg in the above text with equally sized '*' characters?

like, 'Password changed from: 12345 to: abcdefg.' 'Password changed from: ***** to: *******.'

The from and to parts in the above string can vary and i'm not sure how to write an UPDATE query with REPLACE since i have no fixed pattern to look for.

If message text is always in that format, good old SUBSTR + INSTR + REPLACE can do the job.

SQL> WITH test (col)
  2       AS (SELECT '&message' FROM DUAL),
  3       pos
  4       AS (SELECT col,
  5                  INSTR (col, ':', 1, 1)
  6                     colon_1,
  7                  INSTR (col, ':', 1, 2)
  8                     colon_2,
  9                  LENGTH (col) len
 10             FROM test),
 11       inter
 12       AS (SELECT col,
 13                  trim(SUBSTR (col, colon_1 + 2, colon_2 - 4 - colon_1)) old_pw,
 14                  TRIM (RTRIM (SUBSTR (col, colon_2 + 1, len - colon_2), '.'))
 15                     new_pw
 16             FROM pos)
 17  SELECT REPLACE (REPLACE (col, old_pw, LPAD ('*', LENGTH (old_pw), '*')),
 18                  new_pw,
 19                  LPAD ('*', LENGTH (new_pw), '*')) result
 20    FROM inter;
Enter value for message: Password changed from: 12345  to:  abcdefg.

Password changed from: *****  to:  *******.

SQL> /
Enter value for message: Password changed from: abxyz44#  to:  87ZU_3.

Password changed from: ********  to:  *******


replace a part of string. Characters to replace of unknown size , The task is to replace every character by some new character. The new character int main(). {. // Declaring str as 'geeksforgeeks'. string str = "geeksforgeeks" ;. Java String replace() Method. Java String replace() method replaces every occurrence of a given character with a new character and returns a new string. This method allows the replacement of a sequence of character values.

try using REGEXP_REPLACE function.

Replace every character of a string by a different character , The String class has a number of methods for examining the contents of strings, The String class does have four methods for replacing found characters or  Python | Removing unwanted characters from string The generic problem faced by the programmers is removing a character from the entire string. But sometimes the requirement is way above and demands the removal of more that 1 character, but a list of such malicious characters.

select rpad('*', 10, '*')

I think this link can help you:

Manipulating Characters in a String (The Java™ Tutorials , the variable length contains the number 8 (by the way, from this example you see a string consisting of 2 characters from "hello", starting at the third character. the number 0 (false). replace$ (a$, b$, c$, n): gives a string that is like a$, but  Any single character ^# Any digit ^$ Any letter ^u8195. Em space Unicode character value search ^u8194. En space Unicode character value search ^b. Section break ^w. White space (space, nonbreaking space, tab) ^unnnn. Word 2000 Unicode character search, where "n" is a decimal number corresponding to the Unicode character value

Formulas 6. String functions, A regular expression can be a literal character or a string. [character group] allows you to match any number of characters one time, while [^character of double quotes ( " ) or PowerShell will expand the expression as a variable. Using the regular expressions with the -replace operator allows you to  SQL Server REPLACE() function examples. Let’s take some examples of using the REPLACE() function to understand how it works. A) Using REPLACE() function with literal strings. The following example uses the REPLACE() function to replace the tea with the coffee in the string 'It is a good tea at the famous tea store.':

about_Regular_Expressions, The first character of String is at position 1. NumberOfCharacters - Required. The number of characters to replace in String. NewString - Required. The Excel REPLACE function replaces characters specified by location in a given text string with another text string. For example =REPLACE("XYZ123",4,3,"456") returns "XYZ456".

Replace and Substitute functions, s = 'abababab' print(s.replace('a', 'A', 2)) Python Reverse String - 5 Ways and the Best One that we can pass 'count' variable to specify the maximum number of occurrences to replace. Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character. public: System::String ^ Replace (char oldChar, char newChar); C#. public string Replace (char oldChar, char newChar); member this.Replace : char * char -> string.