How to split a string for 2 different matching patterns?

hey guys
i'm trying to split a string, using .split(regular expression), if two different pattern matches but i don't know the exact syntax for it. I want to split the string from letters and punctuations.
This is what i'm doing, obviously it's not working, i'm not too sure if syntax are correct.
String inputDigit [] = input.split("([a-zA-Z]) (\\p{Punct})");Please help me with this, thank you!

Can you describe in more detail what you're trying to
accomplish?ok, basically if you have a string which consists of letters, digits and punctuations. All i'm trying to do or want to do is store all digist within that string into an array. Therefore, i'm using split method to split the string wherever you find a letter or a punctuation. But i don't know what is syntax for using two different patterns at the same time.
// For example if you have a string "Eeyore 61 2.986PoohPiglet007Kanga-23"
// i only want: 61 2 986 007 23. I know i can use substring // but that would be a slightly long process

Similar Messages

  • How To Split the String for "."

    Hi Friends
    I am Using Following Code to Split one String.
    String str = "Jeetendra.choudhary";
    String[] sp_str = str.split(".");
    wdComponentApi.getMessageManager.reportSuccess(str[0]);
    wdComponentApi.getMessageManager.reportSuccess(str[1]);
    but its throwing null pointer exception. 
    when i am using following code its working fine.
    String str = "Jeetendra/choudhary";
    String[] sp_str = str.split("/");
    wdComponentApi.getMessageManager.reportSuccess(str[0]);
    wdComponentApi.getMessageManager.reportSuccess(str[1]);
    what may be the issue and how to split the string with "." ?
    Thanks & Regards
    Jeetendra

    "." is a special character.
    Use
    str.split("\\.");
    Regards
    Benjamin
    Edited by: Benjamin Hansen on Dec 29, 2009 7:52 AM

  • How to call hr_location_api.create_location for different address style with only those fields that belongs specific to  that address style.

    How to call hr_location_api.create_location for different address style with only those fields that belongs specific to  that address style. It should decide at run time means at run time it will come to know the type of address style and based on that only the fields which belong to address details mapped to calling hr_location_api.create_location.
    Thanks in advance.

    You can create a wrapper package on top of the API (hr_location_api.create_location)
    In the wrapper package you set all the values dynamically based on your requirements(say the style and add_line columns are populated on your conditions) and then you call the API.
    Does that not work ?

  • AR - How to split receivable account for several accounts.

    Has enyone know how to split Receivable account for transaction in distribution window on 3 diffrent accounts
    eg.
    Total amount for transaction line is 5000
    I have to create accounting as follow:
    1st Receivable account Dt: 2000
    2nd Receivable account Dt: 2000
    3rd Receivable account Dt: 1000
    1st Revenue account Ct: 500
    2nd Revenue account Ct: 1000
    3rd Revenue account Ct: 3500

    Hi
    This could be possible in R12 using SLA (Sub Ledger Accounting) and not in previous versions
    Regards
    Sivakumar

  • How to split the string by datetime in sql

    Hi,
    How to split the string by datetime in sql, I've a table with comments column stores comments by datetime, while selecting I want to split and show as in rows by each jobref.
    can anyone help me in this please.
    Thanks,

    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call  logged   (28/10/2014 14:56:58) xyz ..... call updated   (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call  logged   (29/10/2014 14:56:58) xyz ..... call updated   (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call  logged   (30/10/2014 14:56:58) xyz ..... call updated  
    output:
    1) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910201'
     2) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910201'
    3) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910201'
    4) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910202'
     5) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910202'
    6) 28/10/2014 14:57:41,  (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910202'
    7) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call  logged ,'Vi2910203'
     8) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910203'
    Thanks,
    See this illustration
    declare @callcentre table (comments varchar(max),lbiref varchar(200))
    insert into @callcentre
    select '(28/10/2014 14:56:14) xyz ..... call logged (28/10/2014 14:56:58) xyz ..... call updated (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
    insert into @callcentre
    select '(29/10/2014 14:56:14) xyz ..... call logged (29/10/2014 14:56:58) xyz ..... call updated (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
    insert into @callcentre
    select '(30/10/2014 14:56:14) xyz ..... call logged (30/10/2014 14:56:58) xyz ..... call updated','Vi2910203'
    SELECT LEFT(p.u.value('.[1]','varchar(max)'),CHARINDEX(')',p.u.value('.[1]','varchar(max)'))-1) AS [Date],
    '(' + p.u.value('.[1]','varchar(max)') AS comments,
    lbiref
    FROM
    SELECT lbiref,CAST('<Root>' + STUFF(REPLACE(comments,'(','</Data><Data>'),1,7,'') + '</Data></Root>' AS XML) AS x
    FROM @callcentre c
    )t
    CROSS APPLY x.nodes('/Root/Data')p(u)
    and the output
    Date comments lbiref
    28/10/2014 14:56:14 (28/10/2014 14:56:14) xyz ..... call logged Vi2910201
    28/10/2014 14:56:58 (28/10/2014 14:56:58) xyz ..... call updated Vi2910201
    28/10/2014 14:57:41 (28/10/2014 14:57:41)xyz ..... call updated Vi2910201
    29/10/2014 14:56:14 (29/10/2014 14:56:14) xyz ..... call logged Vi2910202
    29/10/2014 14:56:58 (29/10/2014 14:56:58) xyz ..... call updated Vi2910202
    29/10/2014 14:57:41 (29/10/2014 14:57:41)xyz ..... call updated Vi2910202
    30/10/2014 14:56:14 (30/10/2014 14:56:14) xyz ..... call logged Vi2910203
    30/10/2014 14:56:58 (30/10/2014 14:56:58) xyz ..... call updated Vi2910203
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to split one page into different frames in ADF?

    Hi,
    Can any one please guide me how to split a jspx into different frames.
    i.e., left frame contains <af:panelSideBar> which contains multiple <af:commandMenuItem> s. And whenver we click on the one <af:commandMenuItem>, it has to show the corresponing page inside center frame in this page itself. Is it possible in ADF? Which component we need to use?
    Can anyone guide me on this?
    Thanks in advance,
    Regards,
    Suresh Kethireddy

    You can use a combination of the ADF Faces 10.1.3 components like:
    af:panelPage
    af:panelSideBar
    af:panelHorizontal
    af:panelGroup
    to organize the screen layout, but it is not the interactive splitter that the 11g product provides.
    You can all all the 10.1.3 ADF Faces Components here:
    http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/tagdoc/core/imageIndex.html

  • HT2731 how do I sign up for itunes match?

    How do I sign up for itunes match?

    Whether you can subscribe to iTunes Match depends upon what country that you are in, it's notyet available in all countries (iTunes Match availability) : subscribing to iTunes Match.

  • How to split this string(char1)char2(char3)char4 into (char1)char2 , .. etc

    how to split this string (char1)char2(char3)char4 into (char1)char2 , (char3)char4?
    String[] result = "(char1)char2(char3)char4".split("\\(");I want :
    result[0] = "(char1)char2" and
    result[0] = "(char3)char4"
    acutally char1,char2,char3, char4 ... is in the form of the below.
    (any charactors except round brace)any charactors except round brace(any charactors except round brace)any charactors except round brace
    I prefer String.split and Pattern.compile().split.
    Edited by: iamjhkang on Feb 5, 2009 3:37 PM
    Edited by: iamjhkang on Feb 5, 2009 3:41 PM

    iamjhkang wrote:
    especially on
    ?= and ?<
    Thanks.The following:
    (?=...)   // positive look ahead
    (?!...)   // negative look ahead
    (?<=...)  // positive look behind
    (?<!...)  // negative look behindare all "look-arounds". See: [http://www.regular-expressions.info/lookaround.html]

  • How to split a string with linefeed character ( LF ) as a delimiter in VB6?

    Hi. I am writing a small program in VB 6.0. 
    I have a string named Data and it contains few characters along with <LF> in it. ( <LF> is a new line/line feed character).
    I want to split this string with <LF> as delimiter and store the tokens in an array. I tried with split function and its giving me type mismatch error. Can anyone tell me how to do it?
    I am giving the pseudo-code below.
    Dim Data as string
    Data = "hello, how are you<LS>good morning guys <LS> hi"
    Dim strarray() as stringMsgbox(Data)
    strarray = split(Data, "<LS>")
    When i see the Data in message box before split function, it shows up in different lines like this:
    hello, how are you
    good morning   guys 
    hi
    I want the final array strarray to be like this:   strarray(0) = "hello, how are you"
    strarray(1) = "good morning   guys "
    strarray(2)  = " hi"
    The spaces can be as it is. Just i need the string to be delimited wherever <LS> is there.
    Please help me as soon as possible. Though it is small one, i am stuck here.
    Thanks in advance,
    Satya.

    Hello,
    This forum is for VB.NET, please check the following resources
    http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/6a0719fe-14af-47f7-9f51-a8ea2b9c8d6b/where-to-post-your-vb-6-questions?forum=vbgeneral
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Splitting a string in different substrings

    Hallo,
    I want to split a string of any length in new substrings and want to save these substrings in different variables.
    I tried as following:
    data:
          string type string value 'Hallo SAP world',  "This could be any string with any lenght
          offset type i value 0,
          str_len type i,
          new_str type string.
    str_len = strlen( string ).
    do 5 times.
      new_str = string+offset(3).
      write : new_str.
      write : ' '.
      offset = offset + 3.
       enddo.
    1_ Has anyone any idea, how to save the new substrings in different variables?
    2_ Since the new substring has length 3. So how many times should the do-loop run?
    Thanks
    ama

    Hi, Muhammed Aftab Alam
    Test the following Sample code it working the same way you are requiring, I have Tested,
    REPORT zfsl_sub_string.
    DATA: main_string TYPE string,
          len_string TYPE i,
          reminder TYPE i,
          string_from TYPE i.
    main_string = 'Hallo SAP World'. " You can give any string here.
    len_string = STRLEN( main_string ).
    DO 3 TIMES.
      reminder = len_string MOD 3.
      IF reminder NE 0.
        CONCATENATE main_string ' ' into main_string SEPARATED BY space.
      len_string = strlen( main_string ).
      ENDIF.
    ENDDO.
    len_string = len_string div 3.
    string_from = 0.
    DO len_string TIMES.
      WRITE: / main_string+string_from(3).
      ADD 3 TO : string_from.
    ENDDO.
    Following too the same as above just add PARAMETER for input String
    REPORT zfsl_sub_string.
    PARAMETERS: pstring TYPE string.
    DATA: "pstring TYPE string,
          len_string TYPE i,
          reminder TYPE i,
          string_from TYPE i.
    *pstring = 'Hallo SAP World'. " You can give any string here.
    len_string = STRLEN( pstring ).
    DO 3 TIMES.
      reminder = len_string MOD 3.
      IF reminder NE 0.
        CONCATENATE pstring ' ' into pstring SEPARATED BY space.
      len_string = strlen( pstring ).
      ENDIF.
    ENDDO.
    len_string = len_string div 3.
    string_from = 0.
    DO len_string TIMES.
      WRITE: / pstring+string_from(3).
      ADD 3 TO : string_from.
    ENDDO.
    Please Reply if any Problem,
    Kind Regards,
    Faisal
    Edited by: Faisal Altaf on Jan 27, 2009 3:06 PM

  • How to change connection string for a form created with b1de

    Hi all
    i've created a form using the Code Generator tool ob B1DE
    My question is how can i set the connection string to a different server and database. doing so after the creation wizard has finished?

    Hi,
    Why do you need to change the connection string? What are you calling "connection string for a form"???
    The only connection string I now about is the one used to connect to the UI API... and this one is fixed for all apps in debug mode and given as parameter when your addon is registered in B1.
    The connection string is filled in the code of your generated addon.
    Please go to the main class of your addon, in the main method you have the following code where the connection string is filled either with the command line parameters (release mode) or with the fixed value given by SAP. This code doesn't need to be changed...
            public static void Main()
                int retCode = 0;
                string connStr = "";
                bool diRequired = true;
                // CHANGE ADDON IDENTIFIER BEFORE RELEASING TO CUSTOMER (Solution Identifier)
                string addOnIdentifierStr = "";
                if ((System.Environment.GetCommandLineArgs().Length == 1)) {
                    connStr = B1Connections.connStr;
                else {
                    connStr = System.Environment.GetCommandLineArgs().GetValue(1).ToString();
                try {
                    // INIT CONNECTIONS
                    retCode = B1Connections.Init(connStr, addOnIdentifierStr, diRequired);
    Regards
    Trinidad.

  • How to Split the string using Substr and instr using loop condition

    Hi every body,
    I have below requirement.
    I need to split the string and append with single quotes('') followed by , (comma) and reassign entire values into another variable. so that i can use it where clause of update statement
    for example I am reciveing value as follows
    ALN varchar2(2000):=(12ERE-3MT-4Y,4IT-5O-SD,OP-K5-456,P04-SFS9-098,90P-SSF-334,3434-KJ4-O28,AS3-SFS0-J33,989-3KL-3434);
    Note: In the above variable i see 8 transactions, where as in real scenario i donot how many transaction i may recive.
    after modification i need above transactions should in below format
    ALTR Varchar2(2000):=('12ERE-3MT-4Y','4IT-5O-SD','OP-K5-456','P04-SFS9-098','90P-SSF-334','3434-KJ4-O28','AS3-SFS0-J33','989-3KL-3434');
    kindly help how to use substr and instr in normal loop or for loop or while loop while modifying the above transactions.
    Please help me to sort out this issue.
    Many Thanks.
    Edited by: user627525 on Dec 15, 2011 11:49 AM

    Try this - may not be the best way but...:
    create or replace type myTableType as table of varchar2(255)
    declare
    v_array mytabletype;
    v_new_str varchar2(4000);
    function str2tbl
             (p_str   in varchar2,
              p_delim in varchar2 default '.')
             return      myTableType
        as
            l_str        long default p_str || p_delim;
             l_n        number;
             l_data     myTableType := myTabletype();
        begin
            loop
                l_n := instr( l_str, p_delim );
                exit when (nvl(l_n,0) = 0);
                l_data.extend;
                l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
                l_str := substr( l_str, l_n+length(p_delim) );
            end loop;
            return l_data;
       end;
    begin
      v_array := str2tbl ('12ERE-3MT-4Y,4IT-5O-SD,OP-K5-456,P04-SFS9-098,90P-SSF-334,3434-KJ4-O28,AS3-SFS0-J33,989-3KL-3434', ',');
          FOR i IN 1 .. v_array.COUNT LOOP
             v_new_str := v_new_str || ''''||v_array(i)||'''' || ',';
          END LOOP;
       dbms_output.put_line(RTRIM(v_new_str, ','));
    end;  
    OUTPUT:
    =======
    '12ERE-3MT-4Y','4IT-5O-SD','OP-K5-456','P04-SFS9-098','90P-SSF-334','3434-KJ4-O28','AS3-SFS0-J33','989-3KL-3434'HTH
    Edited by: user130038 on Dec 15, 2011 12:11 PM

  • How to split a string into tokens and iterate through the tokens

    Guys,
    I want to split a string like 'Value1#Value2' using the delimiter #.
    I want the tokens to be populated in a array-like (or any other convenient structure) so that I can iterate through them in a stored procedure. (and not just print them out)
    I got a function on this link,
    http://www.orafaq.com/forum/t/11692/0/
    which returns a VARRAY. Can anybody help me how to iterate over the VARRAY, or suggest a different alternative to the split please ?
    Thanks.

    RTFM: http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#sthref1146
    or
    http://www.oracle-base.com/articles/8i/Collections8i.php

  • How to split a string which contents 2byte character

    hi all,
      i wanna split a string into substrings  five bits a time
    the problem is the original string may contents 2byte characters
    and if the split bit is a 2byte character we only take the first four bits.
    the 2byte character is used for the next five bits.
      so could you tell how carry is out.
    thanks in advance

    hi all,
      i wanna split a string into substrings  five bits a time
    the problem is the original string may contents 2byte characters
    and if the split bit is a 2byte character we only take the first four bits.
    the 2byte character is used for the next five bits.
      so could you tell how carry is out.
    thanks in advance

  • How to split a string - special character help need

    hai all ,
    i want to split a string
    eg: this is the text file
    dsgdsggdsgdsgds [dhana]
    hsdhsdhdsh
    sdhdshhdsh
    sdjsdhdshdsh hdshsd hsahsh
    hdfhhshs [sekaran]
    dfhdhdh
    i want to take only dhana & sekaran . which is in between the square bracket Special character "[   ] "
    thanks
    dhana

    My now classical RegExp test class:
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    * @author notivago     11/01/2005
    * @version 1.0
    public class RegTest {
        public static void main(String[] args) {
            RegTest test = new RegTest();
            // test.classFind();
            test.dharma();
            test.kharma();
        public void classFind() {
            Pattern p = Pattern.compile( "class\\s+(\\w+)(?:\\s+extends\\s+(\\w+))?(?:\\s+implements\\s+(\\w+)(?:,\\s*(\\w+))*)?\\s*\\{");
            Matcher m = p.matcher( "public class MyClass extends Esta implements Aquela, MaisUma { " );
            m.find();
            System.out.println("Match");
            System.out.println( m.group()  );
            System.out.println( "Class name: " + m.group(1) );
            System.out.println( "Extends: " + m.group(2) );
            for( int i = 3; i < m.groupCount(); i++) {
                System.out.println( "Implements: " + m.group(i) );
        public void stringBreak() {
            Pattern p = Pattern.compile( "([0-9]++\\s++)");
            Matcher m = p.matcher( "1111       22222       333333       444    5     " );
            for( int i = 0; m.find(); i++ ) {
                System.out.println( "Match "+ i + ": [" + m.group(0) + "]" );
        public void dharma() {
            Pattern p = Pattern.compile( "(dhana|sekaran)");
            Matcher m = p.matcher( "dsgdsggdsgdsgds [dhana]\nhsdhsdhdsh\nsdhdshhdsh\nsdjsdhdshdsh hdshsd hsahsh\nhdfhhshs [sekaran]\ndfhdhdh" );
            for( int i = 0; m.find(); i++ ) {
                System.out.println( "Match "+ i + ": " + m.group(0)  );
        public void kharma() {
            Pattern p = Pattern.compile( "[\\[](dhana|sekaran)[\\]]");
            Matcher m = p.matcher( "dsgdsggdsgdsgds [dhana]\nhsdhsdhdsh\nsdhdshhdsh\nsdjsdhdshdsh hdshsd hsahsh\nhdfhhshs [sekaran]\ndfhdhdh" );
            for( int i = 0; m.find(); i++ ) {
                System.out.println( "Match "+ i + ": \t" + m.group(0)  );
                System.out.println( "Sub-match "+ i + ": \t" + m.group(1)  );
    }May the code be with you.

Maybe you are looking for