How to replace a string with asterisks? This is related to my previous post

I guess I now need to replace the middle segment of what is retrieved with asterisks.
So, the string in the middle '99999988' should be replaced with '********'. I am basically trying to mask the middle sement string. The length of the original string is not known but the first segment is 6 characters and 3 segment is 4 characters. The middle sement can be anywhere between 5 to 10 characters. In the example below, its 8 characters.
Can I use REPLACE or TRANSALE functions in here ?
  select substr('456712999999881234', 1, 6) a,
         substr('456712999999881234', 7, length('456712999999881234') - 10) b,
         substr('456712999999881234', -4) c
  from      dual;Thanks

if the middle section is entirely numbers then translate(<middle_section>, '1234567890', '**********')
otherwise rpad('*', length(col)-10, '*')
eg:
select substr('456712999999881234', 1, 6) a,
         translate(substr('456712999999881234', 7, length('456712999999881234') - 10), '1234567890', '**********') b,
         substr('456712999999881234', -4) c
  from  dual;
A      B        C  
456712 ******** 1234
select substr('456712999999881234', 1, 6) a,
         rpad('*', length('456712999999881234')-10, '*') b,
         substr('456712999999881234', -4) c
  from  dual;
A      B        C  
456712 ******** 1234Although thinking about it, I'd just go for the rpad version; requires less processing that using the translate version, and works for more situations (ie. even if there's characters in the middle section, rather than just numbers)
Edited by: Boneist on 16-Jul-2009 16:54

Similar Messages

  • How to replace a movieclip with another movieclip

    How to replace a movieclip with another movieclip
    Hi,
    I am having a swf called tchild.swf... in this i got a
    movclip 'child1'. i am loading this tchild.swf into another swf
    tparent.swf within 'mcloader' movie clip.. i got another movclip
    called 'picture1'
    i am loading tchild.swf into mcloader movclip.. and i want to
    load 'child1' moviclip into picture1..
    how to replace a picture1 movieclip with child1 mc..
    PS: i dont want to load picture1 from library.. its on the
    stage.

    AWT or Swing?

  • Replace a string with another string in a file

    I have to replace a string with another string. Say for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived path like
    "c;\\sample folder\\sample subfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the file.

    I have to replace a string with another string. Say
    for example in a html file it got a line like,
    <a href="##"></a>
    now i want to replace this ## with the full derived
    path like
    "c;\\sample folder\\samplesubfolder\\samplefile.html"
    can someone help me to do this?
    pls tell me from the file opening till closing the
    file.
    public class Buckel {
      final static String CONST = "c:\\sample folder\\samplesubfolder\\samplefile.html";
      public Buckel() {
      public static void main ( String[] argv )  throws Exception {
        int    idx = 0;
        String in  = "<a href=\"##\"></a>",   // We'll imagine this just gets here somehow. If it's on the i/p file then take the '\' out B4 and aft the '##'.
               out = "";
        idx = in.indexOf( "##" );
        if ( idx > 0 ) {
          out = in.substring( 0, idx ) + CONST + in.substring( idx+=2, in.length() );
        System.out.println( out );
    }

  • How to replace key value with character

    Hi Experts
    Can any one tell me, how to replace key value with character, whether it is possible are not. My present report is displaying below format.
    country--city-area-flatnocountry--City-Flatno
    Customer--USACOst1111---UK--HD20--
    C100--11---11--
    C200--11---1--
    For the above example format i am able to display. But now i want to replace 1 with character value for example. For C100
    country is USA at presnt 1 but it should replace with USA.
    You find required format below.
    country--city-area-flatnocountry--City-Flatno
    Customer--USACOst1111---UK--HD20--
    C100--USACOst1111--
    C200--UK--HD20--
    thanks .
    Regards,
    Vishal.

    Hi Markus,
    Thanks for reply,
    Actually i dont have attribute for the customer, the data is maintained in ods, in the form, customer name one info-object and customer value one more info-object this value got text. This value stored in the ods as below
    costomer number  customer value
    C100--USA
    -C100CO
    C100--11-
    C200----
    UK
    C200----
    20
    Please let me know any clarification you need.
    Thanks and Regards,
    Vishal.

  • How to create a String with a specific size?

    how to create a String with a specific size?
    For example I want to create different Strings with the size of 100 , 1000 or 63k byte?

    String are immutable so just initialize it with the number of characters you want.
    You might want to look at java.lang.StringBuffer and see if that's what you want.

  • How to concatenate a string with single quotes

    Hi all,
        how to concatenate a string with single quotes to a variable.
    Sathya

    Hi sathyabama,
    1. simple
    2. use TILDE character <b>(`)</b>
       (just left to the '1' key)
    <b> `'mystring'`</b>
    3. just copy paste
    report abc.
    data : m(100) type c.
    concatenate `'amit mittal'` 'hello' into m separated  by space.
    write m.
    regards,
    amit m.

  • How to print a string with out using main method??

    how to print a string with out using main method??
    if we can tell me with example?
    thanks in adavance
    raja

    Hi,
    actually there's none. The UITableView class needs to "know" the tableView's height so either it can calc <number of rows> times <row height> or it has to sum the height of each single row.
    If the row which needs to be of different size always is the first or the last row you can user a tableHeader or tableFoot view.
    Regards
    Dirk

  • How to replace double quotes with a single quote in a string ?

    Hi All:
    Can some one tell me how to replace double Quote (") in a string with a single quote (') ? I tried to use REPLACE function, but I couldn;t get it worked.
    My example is SELECT REPLACE('STN. "A"', '"', ''') FROM Dual --This one throws an error
    Thanks,
    Dima.

    Whether it is maybe not the more comfortable way, I like the quoting capabitlity from 10g :
    SQL> SELECT REPLACE('STN. "A"', '"', q'(')') FROM Dual;
    REPLACE(
    STN. 'A'{code}
    Nicoals.                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Stepping through a query result set, replacing one string with another.

    I want to write a function that replaces the occurance of a string with another different string.  I need it to be a CF fuction that is callable from another CF function.  I want to "hand" this function an SQL statement (a string) like this:   (Please note, don't bother commenting that "there are eaiser ways to write this SQL..., I've made this simple example to get to the point where I need help.  I have to use a "sub_optimal" SQL syntax just to demonstrate the situation)
    Here is the string I want to pass to the function:
    SELECT
      [VERYLONGTABLENAME].FIRST_NAME,
      [VERYLONGTABLENAME].LAST_NAME,
      [VERYLONGTABLENAME].ADDRESSS
    FROM
      LONGTABLENAME [VERYLONGTABLENAME]
    Here is the contents of the ABRV table:
    TBL_NM,  ABRV    <!--- Header row--->
    VERYLONGTABLENAME, VLTN
    SOMEWHATLONGTALBENAME, SLTN
    MYTABLENAME, MTN
    ATABLENAME, ATN
    The function will return the original string, but with the abreviations in place of the long table names, example:
    SELECT
      VLTN.FIRST_NAME,
      VLTN.LAST_NAME,
      VLTN.ADDRESSS
    FROM
      LONGTABLENAME VLTN
    Notice that only the table names surrounded by brackets and that match a value in the ABRV table have been replaced.  The LONGTABLENAME immediately following the FROM is left as is.
    Now, here is my dum amatuer attempt at writing said function:  Please look at the comment lines for where I need help.
          <cffunction name="AbrvTblNms" output="false" access="remote" returntype="string" >
            <cfargument name="txt" type="string" required="true" />
            <cfset var qAbrvs="">  <!--- variable to hold the query results --->
            <cfset var output_str="#txt#">  <!--- I'm creating a local variable so I can manipulate the data handed in by the TXT parameter.  Is this necessary or can I just use the txt parameter? --->
            <cfquery name="qAbrvs" datasource="cfBAA_odbc" result="rsltAbrvs">
                SELECT TBL_NM, ABRV FROM BAA_TBL_ABRV ORDER BY 1
            </cfquery>
         <!--- I'm assuming that at this point the query has run and there are records in the result set --->
        <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
        <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
        </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
            <!--- The chunck below is a parital listing from my Delphi Object Pascal function that does the same thing
                   I need to know how to write this part in CF9
          while not Eof do
            begin
              s := StringReplace(s, '[' +FieldByName('TBL_NM').AsString + ']', FieldByName('ABRV').AsString, [rfReplaceAll]);
              Next;
            end;
            --->
        <cfreturn output_txt>
        </cffunction>
    I'm mainly struggling with syntax here.  I know what I want to happen, I know how to make it happen in another programming language, just not CF9.  Thanks for any help you can provide.

    RedOctober57 wrote:...
    Thanks for any help you can provide.
    One:
    <cfset var output_str="#txt#">  <!--- I'm creating a local
    variable so I can manipulate the data handed in by the TXT parameter.
    Is this necessary or can I just use the txt parameter? --->
    No you do not need to create a local variable that is a copy of the arguments variable as the arguments scope is already local to the function, but you do not properly reference the arguments scope, so you leave yourself open to using a 'txt' variable in another scope.  Thus the better practice would be to reference "arguments.txt" where you need to.
    Two:
    I know what I want to happen, I know how to make it happen in another programming language, just not CF9.
    Then a better start would be to descirbe what you want to happen and give a simple example in the other programming language.  Most of us are muti-lingual and can parse out clear and clean code in just about any syntax.
    Three:
    <cfloop index="idx_str" list="#qAbrvs#">      <!--- Is this correct?  I think not. --->
    I think you want to be looping over your "qAbrvs" record set returned by your earlier query, maybe.
    <cfloop query="qAbrvs">
    Four:
    <cfset output_str = Replace(output_str, "#idx_str#", )  <!--- Is this correct?  I think not. --->
    Continuing on that assumption I would guess you want to replace each instance of the long string with the short string form that record set.
    <cfset output_str = Replace(output_str,qAbrs.TBLNM,qAbrs.ABRV,"ALL")>
    Five:
    </cfloop>               <!--- What am I looping on?  What is the index? How do I do the string replacement? --->
    If this is true, then you are looping over the record set of tablenames and abreviations that you want to replace in the string.

  • Replacing the string with a sbstring

    String query="elect empname,empDate,CustNo from EmpData where (empname='smith') and ( empDate> '22/10/2005' and CustNo > '1' )";
    the date here is dd/mm/yyyy formatt..
    i want extract that date and change it to mm/dd/yyyy formatt and re create the same query with changed date due to some contraints in my application.not only this date i may get more dates cause its generated dynamically..
    how can achieve this..
    Regards,

    thanks,
    its not about jdbc..some times the user may enter the arabic dates.i will decide wther its arabic year are english year based upon the year digit.so if it is arabic year then i have to find the appropriate gregorian date based upon the arabic date.because in date base we store only grergorian dates..for this case iam asking for this..if found any arabic date then i will replace that date with appropriate gregorian date..i need to know how can replace this..i have the functionality for converting the arabic date to gregorian.
    regards,

  • How to create a String with comma ?

    Hi All,
    I have a table with 10 records(employee name) and i have to make a string
    with comma delimiter and at the end with "."
    Can anybody tell me how to write a Java program for this ?
    Thanks in advance.

    // I believe the following example gives you the answer.
    class stringEG {
         public static void main(String args[]) {
         String emprs[] ={"1","2","3","4","5","6","7","8","9","10"};
         String vempname = "";
         for(int i=0; i<emprs.length; i++) {
         if(i == (emprs.length-1))
              vempname = vempname + emprs[i] + ".";
         else
              vempname = vempname + emprs[i] + ", ";
         System.out.println("vempname : "+vempname);
    Here dont assume that I asked you to get all the results and putting
    it into the string arrays. But its a simple example to suit your requirement.
    The half-way coding below answers your question, I hope.
    vempname = "";
    while (emprs.next()) {
    if(emprs.isLast())
    vempname = vempname + emprs.getString("empname") + ".";
    else
    vempname = vempname + emprs.getString("empname") + ", ";
    // nats.

  • How to replace the '&' character with '&' in xi

    Hi,
    i need to replace the '&' character with ' &amp;'.but i f i am converting it is displaying as '&' because internally '&amp;' = '&'.
    beacuse of this it is not converting.
    is there any possiblity to change the  standard conversion in xi.

    Graphical mapping does not support special character like & , <,> to be mapped.
    You can encode & as and in UTF-8 only.
    if you want the special character to be used, Opt XSLT mapping with ISO-8859-1 encoding
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="ISO-8859-1"/>
    <xsl:template match="/">
    <xsl:copy-of select="*" />
    </xsl:template>
    </xsl:stylesheet>
    How to Work with Character Encodings in Process Integration (NW7.0)
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/502991a2-45d9-2910-d99f-8aba5d79fb42

  • How to concatenate a string with spaces

    Dear experts,
    I would like to concatenate a string with three spaces, for example,
    CONCATENATE 'X' SPACE SPACE SPACE 'Y' INTO LV_RESULT.
    However, the result I got from executing the above statement is not 'X   Y' as I want, but rather 'XY'.
    I did try
    CONCATENATE 'X' '***' 'Y' INTO LV_RESULT.
    REPLACE '***' with '   ' INTO LV_RESULT.
    still doesn't work.
    How can I write ABAP code to archive such a result?
    Any idea would be appreciated.
    Vitthavat A.

    dear  Oliver Hütköper and koolspy,
    I tried your solutions, and it works.
    so i awarded points to you.
    anyway, while trying the 'respecting blanks', i got an error:
    "".", "IN BYTE MODE", "SEPARATED BY ..." or "IN CHARACTER MODE" expected"
    not sure what it means. but it's ok. the problem has been solved.
    thanks again.

  • How to replace westell 6100 with westell 327w?

    Hi all,
    I am currently using a Westell 6100 and I just inherited a Westell 327W from my brother who switched over to FIOS.
    Can I replace the 6100 with the 327W? And how do I go about doing that?
    Any suggestions or recommendations would be greatly appreciated.
    Cheers!

    If the 327w has newer firmware on it, you can just factory reset it and then connect it up. Once it is online, visit http://192.168.1.1/ and use admin/password respectively as the login information. Then, set a new password for the gateway.
    Once done, visit http://192.168.1.1/verizon/redirect.htm and choose the disable button. Assuming the modem has been able to get a connection at this time, you should be online.
    ========
    The first to bring me 1Gbps Fiber for $30/m wins!

  • How to replace an MDB with a servlet

    I got a situation to replace an MDB with a servlet,How can I do that,more appreciated if u send me some sample code.

    Hi,
    An MDB can be replaced by a normal java class by doing the following.
    Make a jndi lookup for the queue/topic connection factory and then create a javax.jms.QueueConnection. Then create a javax.jms.QueueSession using this connection. Make a JNDI look up for the Queue. Create a javax.jms.QueueReceiver using the created QueueSession. Call start on the QueueConnection and receive a message by calling the receive method on QueueReceiver.
    Thanks,
    marvlex

Maybe you are looking for

  • Can you use the same Hulu Plus subscription on both the iPad and PS3?

    Can anyone confirm whether a Hulu Plus subscription for the iPad also works for Sony's PS3 (or vice versa)? That is, can you pay ONE $9.99/month fee and have access from both the iPad and the PS3? The Hulu website seems to suggest that this is possib

  • Need to reinstall Os X Mavericks,

    '' This apple id has not yet been used with the App Store. Please reveiw your account information '' I just got it back from the repair shop and everything has been switched out, hardrive, battery, motherboard etc.  and i cant get onto it without ins

  • Problem in writiing data to UTL_File

    Hello Friends, I'm using UTL_FILE to write the data into csv file, but in the table 1 description column is there which contains 3000 characters. My problem is i'm not able to write more than 750 characters in csv file and if i tried to do so then ge

  • Changing G/L Account

    Hello, I’m trying to change P&L statement acct to Balance sheet account of a G/L account. The balance of the G/L account is 0 and the  fbl3n transaction shows two documents (DZ and DA). When I try to change the account, the following error message is

  • Music gone by upgrading but it still uses my space

    So I have an old iPod Touch 4G (I know that it isn't that old) and for some reason it couldn't upgrade from iOS 3 to iOS 5 so I did it on a PC and it worked but my music got moved to another folder so I couldn't delete it so now I am missing over 2.7