How to find out if a long String has a "subString" twice or more.

I need to find out if a long String has the same number twice or more.
I need to look matches for numbers running from 000, 001....999 and if a number is found twice or more, return that number and lines there were found.
example String:
-;000 ; 1 ; 2006-12-11 ; -; job;
x;001 ; 2 ; 2006-12-11 ; 2006-12-12; do this
-;002 ; 3 ; 2006-12-11 ; -; work
-;003 ; 0 ; 2006-12-11 ; -; some
-;004 ; 2 ; 2006-12-11 ; -; thing
x;005 ; 1 ; 2006-12-11 ; 2006-12-11; reads
-;003 ; 0 ; 2006-12-11 ; -; here
Should return from example String:
003 at lines 4 and 7
Any ideas?

So there are newlines in the String?
You could use a StringTokenizer to break the String into lines, then searching on each line if it contains any of the search strings. (You need to clarify if a line can contain more than one search string).
Probably you should use a Map<String, Integer> to record the searchcounts.
Or an int[] Array if you are really sure that the Strings you search for really are numbers.
Another option is to use:
LineNumberReader lnr = new LineNumberReader(new StringReader(searchString));This will save you from explicitly having to take care for the line number.
In any case your example looks like the individual lines are semicolon separated fields and the numbers you search for always are in column two.
So after breaking up the original String in lines, you could use another StringTokenizer to break up the line in fields.

Similar Messages

  • How to find out if your BB line has been capped?

    Is there somewhere I can go to find out if my BB line has been capped? I had an email form BT about a month ago warning me I might exceed my download limit. In the end I did not exceed my limit for the month. But it was shortly after that my BB speed was cut in half and has remained that way ever since. I have had 2 engineers out who can find nothing wrong with the exchange, the line or the equipment in my house. Despite at least 3 SNR resets, my IP profile has been fixed at 750k for the whole time. My IP profile was 2000k or more before the speed was cut.
    I just wonder if there is anyway to tell if your BB line has been throttled.

    "it is very likely a local noise issue that your line is picking up it is not a line fault this is is why bt cannot find the fault the problem could be caused by many things microwaves central heating pumps computer monitors poweresupplies and many similar items"
    If there is a local noise issue as you suggest, How would one detect such a thing? You can't just switch everything off in a house and leave it for 3 to 5 days to see if the BB speed increases. Surely the tests the the engineers did when they came out to see me would have detected any noise on the line when they tested the line.
    The thing I find most frustrating is BT don't even seem able to admit I have any sort of problem at all. The fact I have had a stable connection for years and then suddenly it drops by half overnight seems not to be considered a problem. I think I might just change to another ISP. I really don't think it can be any worse than this.

  • How to find out if someone's phone has I cloud backup?

    Is there a way to find out if an Apple user has iCloud backup on their phone if you have their Apple ID and user password? My daughter has been up to something very suspicious lately and I would like to monitor her phone. But I need to know she has iCloud backup. So someone could please let me know if there's a way to figure this out without having access to the phone because she lived in a different state that would be wonderful thank you

    Sounds to me you're up to something very suspicious.

  • How to find out if a query(report) has a role.

    I want to find out if a query(report) has a role and what the role name is.
    Do anybody know a function or a table?

    goto SU01 , give ur username , click on roles tab , and click F1 on role field , then goto technical attributes , and use where-used-list of that dataelement , u will lot of tables on Roles and its attributes
    You can look up AGR* tables in SE16
    Please give me reward points if it is useful.
    Thanks
    Murali Poli

  • How to find out the index in string.

    Hello Experts,
    I have a requirement in which i have to find out the index of the last space before the 50th position in a string.
    is there any way other than spliting the string.
    e.g. if string is - 'aaaa aaaa aaa........ aaa aaa'(length is more than 50)
    i want the last space before 50th char.because i want to split the string before last word withing 50 th character
    please help.
    Thanks,
    Shweta

    Hi Shweta,
    You can build up the logic from this below program.
    data: line(75) value 'abcdefghijk lmnopqrstuvwxyz zyxwvutsrqponml kjihgfedc ba',
           n_line(50),
           off type i,
           val1(50),
           val2(50).
    CALL FUNCTION 'STRING_REVERSE'
      EXPORTING
        STRING          = line(50)
        LANG            = ' '
    IMPORTING
       RSTRING         = n_line
    EXCEPTIONS
       TOO_SMALL       = 1
       OTHERS          = 2.
    IF SY-SUBRC NE 0.
       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    SPLIT n_line at space into val1 val2.
    off = strlen( val1 ).
    off = 50 - off.
    write: 'The index of the last space before the 50th position is at ', off.
    Hope this may help you.
    Regards,
    Smart Varghese

  • How to find out that an art item has spot color using script?

    Hi all,
    I have a number of art items on a document, some of them are filled with spot colors and some of them are with process color.
    Is there any method by which I can find out which color type(spot or process) is applied to the selected art item?
    Thanx in advance...

    Thanx for the reply carlos....
    But I am not able to use "icolor.typename". There is nothing like "typename" showing in the properties.
    I am using it like this:
    var app:com.adobe.illustrator.Application = Illustrator.app;
                                            var pathArt:PathItem;
                                            var allPaths:PathItems           = doc.pathItems;
                                            if ( app.documents.length > 0 && doc.pathItems.length > 0)
                                                           var colorValue:com.adobe.illustrator.Color;
                                                           //Fill color to the selected object.
                                                           for (var i:int = 0; i < doc.pathItems.length ; ++i)
                                                                          pathArt = allPaths.index(i);
                                                                          if(pathArt.selected)
                                                                                         colorValue = pathArt.fillColor;
                                                                                         trace(colorValue.typename);              //But colorValue doesn't show any property like "typename".
    Do am i missing some thing?
    Thanks...

  • How to find out what files a package has installed?

    Sometime you installed a package, but you don't know the name of the command to run and you don't know the name and location of the configuration files. There are conventions but is there a way to show those information explicitly?

    aberkoke wrote:
    You can try
    $locate
    for example. you write
    $locate firefox
    and you will see all files about firefox.
    That's a partial solution. Suppose I installed a package called gtk-vim, but the binary is gvim and I didn't know that. If I use
    locate gtk-vim
    it will not find "gvim".
    Besides, different packages may install files with names identical or partially identical. What I want to find out is what files a specific package installed or removed, or changed, just like the deb package manager in ubuntu.

  • How to find out in which order locks are aquired by one or more sessions.

    hi,
    i am using following query to find locking of two sessions .
    SELECT resource_database_id, t.resource_type , t.resource_associated_entity_id,partitions.index_id,blocking_session_id,
                indexes.name as index_name,o.name,
        t.request_status, t.request_mode,t.request_session_id,
        t.resource_description 
        ,s.total_elapsed_time,s.start_time, convert(varchar ,getdate() - s.start_time, 114)
        ,s.wait_type,s.wait_time
        ,s.last_wait_type,s.lock_timeout,s.row_count
        ,s.*,o.*,t.*
        FROM sys.dm_tran_locks t
        LEFT JOIN sys.objects o on t.resource_associated_entity_id=o.object_id
        LEFT JOIN sys.dm_exec_requests s ON s.session_id=t.request_session_id
        left join sys.partitions on partitions.hobt_id = t.resource_associated_entity_id
        left join sys.indexes on indexes.object_id = partitions.object_id and indexes.index_id = partitions.index_id
        WHERE s.session_id in (51,52) ORDER BY s.start_time,s.total_elapsed_time
    resource_type resource_associated_entity_id request_session_id request_mode index_name name resource_description
    DATABASE 0 51 S NULL NULL
    OBJECT 2094278866 51 Sch-S NULL wt
    OBJECT 2094278866 52 IX NULL wt
    PAGE 72057597150887936 52 IX PK_wt NULL 1:204815
    KEY 72057597150887936 52 X PK_wt NULL (4fb98fd9bfad)
    DATABASE 0 52 S NULL NULL
    Q1)i wanted to know session id 52 acquired object,page,key and database locks in same order or it was opposite
    how can i find the order of aquisition of locks by (one or two session).
    Q2)i have express edition advance of sqlserver 2008 r2 , it possible to trace every event with out using profiler as u know it
    does not ship with it 
    yours sincerley

    http://blogs.conchango.com/jamesrowlandjones/archive/2009/05/28/the-curious-case-of-the-dubious-deadlock-and-the-not-so-logical-lock.aspx
    select *,%%lockres%%
    from    dbo.Table(nolock)
    where    %%lockres%% IN('(4fb98fd9bfad)')
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to find out what access a group has

    Hello. I inherited a portal that has a lot of groups & some of which do not appear to be in use from what I can see. I would like to get rid of these groups if they are no longer viable. So, I would like to know if there are any api's that I could use to interrogate a particular group and to list any items the group has access to.
    Thanks!
    Todd

    The table portal.wwsec_sys_priv$ contains the information on what components, items, pages, etc. a group has privileges to. Here's one [example query|http://forums.oracle.com/forums/thread.jspa?threadID=461824] someone posted awhile back.

  • Query to find out if the numeric string has letters in it. Please, help!

    Hi, everyone!
    Could you please help me in constructing the following query:
    I want the query to return the records, for which a specified column contains at least 1 alpha-numeric character in it. For example, if I search the Items table, I want the rows with the following Item_Number values be returned: "34265af6", "bbbbbbbb", "9808677y" etc...
    Thanks a lot.
    Regards,
    Eugene.

    Would you consider the Null value for "p_string" input parameter as being NUMBER or otherwise? That's an interesting question. The function and query as is would treat nulls as numbers, consistent with how Oracle would treat a null as a potential number, by not raising any error when asked for to_number(null). However, if you wanted to exclude nulls, you could just add an additional filter condition to the where clause. See examples below.
    -- selecting to_number(null) does not raise an error:
    SQL> SELECT TO_NUMBER (NULL) FROM DUAL
      2  /
    TO_NUMBER(NULL)                                                                
    -- is_number(null) is considered numeric:
    SQL> SELECT is_number (NULL) FROM DUAL
      2  /
    IS_NUMBER(NULL)                                                                
    Y                                                                              
    -- combination of Oracle and user-defined
    -- functions considers null as numeric:
    SQL> SELECT DECODE (LTRIM (NULL, '0123456789-+E/.,'),
      2                NULL, is_number (NULL),
      3                'N')
      4  FROM   DUAL
      5  /
    DECODE(LTRIM(NULL,'0123456789-+E/.,'),NULL,IS_NUMBER(NULL),'N')                
    Y                                                                              
    SQL> -- additional test data:
    SQL> INSERT INTO items VALUES (NULL)
      2  /
    1 row created.
    SQL> COMMIT
      2  /
    Commit complete.
    SQL> SELECT * FROM items
      2  /
    ITEM_NUMBE                                                                     
    ABC123                                                                         
    ABC                                                                            
    DEF123                                                                         
    123                                                                            
    C123                                                                           
    XYZ                                                                            
    GHI                                                                            
    8 rows selected.
    SQL>
    SQL>
    SQL> -- unmodified select statement
    SQL> -- treats nulls as numbers
    SQL> -- and doesn't include null value
    SQL> -- in result set when searching
    SQL> -- for non-numbers:
    SQL> SELECT *
      2  FROM   items
      3  WHERE  DECODE (LTRIM (item_number, '0123456789-+E/.,'),
      4                NULL, is_number (item_number),
      5                'N') = 'N'
      6  /
    ITEM_NUMBE                                                                     
    ABC123                                                                         
    ABC                                                                            
    DEF123                                                                         
    C123                                                                           
    XYZ                                                                            
    GHI                                                                            
    6 rows selected.
    SQL>
    SQL>
    SQL> -- modified select statement
    SQL> -- treats nulls as non-numbers
    SQL> -- and includes nulls in result set
    SQL> -- when searching for non-numbers:
    SQL> SELECT *
      2  FROM   items
      3  WHERE  DECODE (LTRIM (item_number, '0123456789-+E/.,'),
      4                NULL, is_number (item_number),
      5                'N') = 'N'
      6  OR     item_number IS NULL
      7  /
    ITEM_NUMBE                                                                     
    ABC123                                                                         
    ABC                                                                            
    DEF123                                                                         
    C123                                                                           
    XYZ                                                                            
    GHI                                                                            
    7 rows selected.

  • How to find out all table names which has a particular data

    Hi,
    How could i get all the table names from a database(for a schema) which has data 'KST6490' in one of the fileds in the table.There are many tables with this
    data. Data type is Varchar2. Thanks.

    One approach would be to create a procedure which retrieves the name of all tables in the schema using the user_tables view. Then use the user_tab_columns view to get all the column names and types. If the type is varchar2, then dynamically create a sql statement which runs a query on that column using the value which you are looking for. You would need two cursor loops for this approach: one for tables and one for columns. This approach requires good PL/SQL programming skills.
    Alternately, many query tools, such as Golden, provide a search capability on query results. Just do a select * from the table and search on the results. This would need to be done table by table and the results would have to fit in the memory available to the tool.
    Alternately, you can write table contents to a text file on the a server and then search the text file using operating system tools such as grep. This would require good OS scripting skills.

  • How  to find out list of users who has logged into webtools

    Hi All,
    From a database administration and monitoring traffic point of view we want to know who has logged into our web tools web site for a given period.  Is there a easy way to have this information. basically user ID , date and time are info we need. (need all users - with or without orders)
    any ideas welcome.
    Regards
    David

    Hello,
    The easiest way to accomplish this is by creating a report.
    Use the SQL query
    SELECT     UserID, LastVisitDate
    FROM         Users
    ORDER BY LastVisitDate DESC
    And a template that looks something like this:
    <html>
    <head>
    <title>%%ReportName%% - %%Today, {0:d}%%</title>
    %%StyleSheet%%
    </head>
    <body>
    <center>
    <h1>%%ReportName%%</h1>
    <table width=800 cellpadding=1 cellspacing=0 border=1>  
    <tr>
    <td><b>User ID</b></td>
    <td><b>Last Visit</b></td>
    </tr>
    <section name="uservisit">
    <tr>
    <td>%%UserID%%</td>
    <td>%%LastVisitDate%%</td>
    </tr>
    </section>
    </table>
    </center>
    </body>
    </html>

  • How can find out long run quries?

    Hi,
    I have some question
    how can find out long run queries , i have use v$session but i have not find out,pls how can find out
    these queries.

    v$session_longops has some limitations, for example it records only some operations see more [url http://www.gplivna.eu/papers/v$session_longops.htm]here
    Another possibility might be using statspack and/or [url http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14211/autostat.htm#PFGRF02601]AWR
    From docs:
    The most current instructions and information on installing and using the Statspack package are contained in the spdoc.txt file installed with your database. Refer to that file for Statspack information. On Unix systems, the file is located in the ORACLE_HOME/rdbms/admin directory. On Windows systems, the file is located in the ORACLE_HOME\rdbms\admin directory.
    Gints Plivna
    http://www.gplivna.eu

  • How to find out the user who has created  a new field in the custom table.

    How to find out the user details who has created  a new field in the custom table.
    Thanks,
    Joan

    Hi Jesudasan ,
    You can know the user details with version management.Please find the
    below procedure to know.
    Go to table->Utilities tab->version->Version management->Compare the previous one .
    Hope this solves the issue,Let me know if you have any issues.
    Thanks,
    Rajani

  • How to find out whether a particular changed by some user

    Hi gurus,
                I am just trying to figure it out how to find out whether a particular user has changed a particular table or not. In other words table changes history. If any of you know about it please let me know.
    Thankyou
    Jason

    Jason,
      Ajay mentioned changes to Table not for Data. If you are looking for Changes to Table Data... you need to check System Log SM21. check for that perticular period.
    Nagesh Ganisetti.
    Assign points if it helps.

Maybe you are looking for