Strings: Finding the index value of the 1st alphabet character

Hi
I'm trying to find a way of finding the index position of the 1st alphabetic character i.e. letters from "a" to "z" in a string line.
I've tried looking at the java doc pages on the String Class which contains methods such "indexOf" but i'm very confused on how this all works??
Could someone please help me.
Thanks
Rahul

Another way is to use regular expressions:
import java.util.regex.*;
class RegExTest {   
    public int indexOfRegEx(String regex , String inString){
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(inString);
        boolean found = m.find();
        return found ? m.start() : -1;
    public static void main(String[] args) {
        RegExTest test = new RegExTest();
        System.out.println(test.indexOfRegEx("[A-Za-z]", "a124321"));
        System.out.println(test.indexOfRegEx("[A-Za-z]", "12A4321"));
        System.out.println(test.indexOfRegEx("\\p{Alpha}", "124321"));
        System.out.println(test.indexOfRegEx("\\p{Alpha}", "124321a"));
}

Similar Messages

  • Finding the 1st place character

    Hi,
    I have string and I want to check what character is present at the 1st place of the string.Can anyone tell how to do this?
    Thanks.

    Hi,
    Just use offsets.
    data: temp type string value 'abc123'.
    data: result(1) type c.
    result = temp+0(1).
    write: result.
    Regards,
    Vikranth

  • How can i find the 1st business day of the week ?

    Hi,
    How can i find the 1st business day of the week excluding saturaday,sunday and holidays? i have holiday table which contains the columns name HolidayDate and HolidayDescription.
    Ex:
    10-1-2011 is monday(i.e) 1st business day.check If it is in holiday table,then return the result as 11-1-2011 else return the result as 11-1-2011(which is the first business day of this week).
    Can anyone tell me the Query to solve it?

    Does this help:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (SELECT TRUNC(SYSDATE,'IW') holiday FROM dual
      2  UNION SELECT TRUNC(SYSDATE + 7,'IW') from dual)
      3  SELECT MIN(Dat),wk FROM
      4  (SELECT TO_CHAR(dat,'IW') wk,dat FROM
      5  (SELECT dat + lvl dat FROM
      6  (SELECT TRUNC(SYSDATE,'RRRR') dat, level - 1 lvl
      7  FROM dual
      8  CONNECT BY level <= TO_DATE('31-DEC'||TO_CHAR(SYSDATE,'RRRR')) - TRUNC(SYSDATE,'RRRR'))
      9  ) x
    10  WHERE x.dat NOT IN (select holiday from t))
    11  WHERE TO_CHAR(Dat,'DY') <> 'SAT'
    12  AND TO_CHAR(dat,'DY') <> 'SUN'
    13* group by wk
    SQL> /
    MIN(DAT)  WK
    04-JAN-11 01  -- since 03-JAN-2011 is in holiday list, 04 is taken as first business day of first week
    11-JAN-11 02  -- similar to week 1
    17-JAN-11 03
    24-JAN-11 04
    31-JAN-11 05
    07-FEB-11 06
    14-FEB-11 07
    21-FEB-11 08
    28-FEB-11 09
    07-MAR-11 10
    14-MAR-11 11
    21-MAR-11 12
    28-MAR-11 13
    04-APR-11 14
    11-APR-11 15
    18-APR-11 16
    25-APR-11 17
    02-MAY-11 18
    09-MAY-11 19
    16-MAY-11 20
    23-MAY-11 21
    30-MAY-11 22
    06-JUN-11 23
    13-JUN-11 24
    20-JUN-11 25
    27-JUN-11 26
    04-JUL-11 27
    11-JUL-11 28
    18-JUL-11 29
    25-JUL-11 30
    01-AUG-11 31
    08-AUG-11 32
    15-AUG-11 33
    22-AUG-11 34
    29-AUG-11 35
    05-SEP-11 36
    12-SEP-11 37
    19-SEP-11 38
    26-SEP-11 39
    03-OCT-11 40
    10-OCT-11 41
    17-OCT-11 42
    24-OCT-11 43
    31-OCT-11 44
    07-NOV-11 45
    14-NOV-11 46
    21-NOV-11 47
    28-NOV-11 48
    05-DEC-11 49
    12-DEC-11 50
    19-DEC-11 51
    26-DEC-11 52
    52 rows selected.
    SQL>

  • How can if find the most repeated character and number ???

    Hi,
    I have a question. For instance, if we have a text file which contains:
    aaabbbhhhhhhtttttsjs12366
    How can i find the most repeated character and number. I have to add this code to the following program:
    I will aprreciate if you can help.
    Regards,
    Serkan
    import java.io.*;
    public class LineLen {
         public static void main(String args[]) throws Throwable {
              final String filename = "deneme1.txt";
              BufferedReader infile = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
              String line = infile.readLine();
              int linenum = 0;
              while (line != null) {
                   int len = line.length();
                   linenum++;
                   System.out.print(linenum + "\t");
                   for (int i = 0; i<len; i++)
                   System.out.print("*");
                   System.out.println("");
                   line = infile.readLine();
    }

    For a small alphabet like English, array migt be used:
    //in a for loop
    ++array[s.charAt(i)];For a big alphabet like chinese, HashMap might be barely used:
    map.put(s.charAt(i), increment(map.get(s.charAt(i))));
    // increment is a user defined method, possibly for an Integer object,
    // that returns a new Integer object

  • Finding the occurences of | character in a string

    Hi There,
    I want to restrict the occurrences of | character in a string to some number. How can I make this check using regular expressions.
    Thanks,
    --JJ                                                                                                                                                                                                                                                                                                                               

    sabre150 wrote:
    guitar_man_F wrote:
    sabre150 wrote:
    jose wrote:
    So can you please suggest me a sample regex which will do this.
    --JJErr.. err.. err.. reply #2?Not quite. I believe he said restrict it to a certain max number of |, not remove all instances. I think.
    Look again. I remove anything that is NOT a '|' char and then count what is left.Oops! My bad! You're right. That would work.
    - Adam

  • How to find the 1st sunday in a month

    v_end := '01-nov-' || in_year;
    v_sql_text := 'select next_day('''||v_end||''',''sunday'')+7 from dual';
    this works except that nov 1st is a sunday. better idea?

    Warren, besides being a big overkill (comparing to NEXT_DATE solution), it is, same as NEXT_DAY solution, NLS dependent. Assume you have a client in Germany:
    SQL> alter session set nls_date_language=german;
    Session altered.
    SQL> select next_day(sysdate,'SUNDAY') from dual;
    select next_day(sysdate,'SUNDAY') from dual
    ERROR at line 1:
    ORA-01846: not a valid day of the week
    SQL> NLS independent solution I am aware of is based on Julian date 1 being Tuesday and therefore Julian date 6 being SUnday:
    SQL> select to_char(to_date('1','J'),'Day') from dual;
    TO_CHAR(T
    Tuesday
    SQL> select to_char(to_date('6','J'),'Day') from dual;
    TO_CHAR(T
    Sunday
    SQL> Therefore, NLS independent first Sunday of the month is:
    SQL> alter session set nls_date_format='FMDay, Month DD YYYY';
    Session altered.
    SQL> alter session set nls_date_language=american;
    Session altered.
    SQL> SELECT NEXT_DAY(
      2                  TRUNC(SYSDATE, 'MM') - 1,
      3                  to_char(to_date('6','J'),'Day')
      4                 )
      5    FROM dual
      6  /
    NEXT_DAY(TRUNC(SYSDATE,'MM')
    Sunday, February 4 2007
    SQL> alter session set nls_date_language=german;
    Session altered.
    SQL> SELECT NEXT_DAY(
      2                  TRUNC(SYSDATE, 'MM') - 1,
      3                  to_char(to_date('6','J'),'Day')
      4                 )
      5    FROM dual
      6  /
    NEXT_DAY(TRUNC(SYSDATE,'MM')-
    Sonntag, Februar 4 2007
    SQL> alter session set nls_date_language=french;
    Session altered.
    SQL> SELECT NEXT_DAY(
      2                  TRUNC(SYSDATE, 'MM') - 1,
      3                  to_char(to_date('6','J'),'Day')
      4                 )
      5    FROM dual
      6  /
    NEXT_DAY(TRUNC(SYSDATE,'MM'
    Dimanche, Février 4 2007
    SQL> SY.

  • What do you do in a query in order to find the 1st day of last month ?

    i use a
    select trunc(trunc(sysdate,'mon')-1,'mon') from dual;
    what about you guys ?

    Hi,
    Of all the solutions, I like yours
    add_months(trunc(sysdate,'mm'),-1)or doing the operations in the opposite order, like Sentinel did
    trunc(add_months(sysdate,-1),'mm')best, mainly because:
    (1) it's easy to read and understand
    (2) it's easy to modify (in case you want the first day from three months ago, or six months in the future)
    By the way, after you post something on this forum, if you see that you've made a mistake, you can correct it. Click on the second icon to the left of "Reply". (What is that: a hand holding a pencil?) You don't need to post a second message.

  • Finding the 15th of Every Month

    Hi,
    I have declared expiration start date and end date variables. The expiration Start Date always start from 1st of the Month or 15th of the Month. Right now I am incrementing the expiration start date by one Month :
    for example if my exp start date : 2010-01-01
    and exp end date : 2010-04-01
    I dissect the dates from start date :
    2010-01-01
    2010-02-01
    2010-03-01
    2010-04-01
    Instead of incrementing the start date by 1 month as am currently doing I would want to increment by 1st and 15th of every month :
    2010-01-01
    2010-01-15
    2010-02-01
    2010-02-15
    2010-03-01
    2010-03-15
    2010-04-01
    I tired directly to add days but that does not work. Please suggest is there a way to increment my exp_start_date variable so that it increments by exaclty 1st or 15th of the month.
    Below is the code :
    declare
    exp_start_date varchar2(15):='2010-01-01';
    exp_end_date varchar2(15) :='2010-04-01';
    v_exp_start_dt date := to_date(exp_start_date,'yyyy/mm/dd');
    v_exp_end_dt date := to_date(exp_end_date,'yyyy/mm/dd');
    v_tmp integer;
    begin
    while v_exp_start_dt <= v_exp_end_dt loop
    select nvl(sum(dc.daily_count),0) into v_tmp
    from daily_counts_summary dc
    where
    and   dc.expiration_dt = v_exp_start_dt
    and  v_exp_start_dt between v_exp_start_dt  and v_exp_end_dt
    v_exp_start_dt := add_months(v_exp_start_dt,+1) ;
    end loop;
    end;Thanks,
    eva

    Hi,
    I finally got close on finding the 1st and 15th of every month :
    Below is the code that works with the sysdate object :
    SELECT days
        FROM   (SELECT SYSDATE + ROWNUM AS days
                  FROM   DUAL
                 CONNECT BY LEVEL <= TO_DATE ('01-SEP-2011', 'DD-MON-YYYY') - SYSDATE)
       WHERE  TO_CHAR (days, 'dd') IN (1, 15)Instead of using the sysdate object I want to use variable which I have in the query . The variable is of data type date.
    I tired various combination's but I am unable to replace the sysdate with my query variable.
    here is the code I am trying :
    SELECT days
       FROM   (SELECT TO_CHAR('01-FEB-2011', 'dd-Mon-yyyy') + ROWNUM AS days
                 FROM   DUAL
                 CONNECT BY LEVEL <= TO_DATE ('01-MAY-2011', 'DD-MON-YYYY') - TO_CHAR('01-FEB-2011', 'dd-Mon-yyyy'))
             WHERE  TO_CHAR (days, 'dd') IN (1, 15)It always throws the erorr : ORA00092- Inconsistent Datatypes expected a number and got DATE.
    Please advice as am very close to the solution.
    Thanks,
    eva

  • Given a string, how do you find the numeric value in sparse ring?

    Situation: I receive the string value of the sparse ring, and a control reference to the same type of control, but not the control that sourced the string. How can I convert the string, into the actual numeric value of the ring? For example:
    Using the "VISA Select Event Type" ring (Functions -> Instrument I/O -> VISA -> Advanced -> Event -> Select Event Type.ctl), lets say I get the string "ServiceRequest" how do I convert that into 1073684491, the actual value of the ring?
    This is a rework of an existing function that worked fine with "normal" rings.
    Thanks.

    Unfortunately this method will not work, its a generic routine that must be able to take any ring, so I can't hardwire the cases to known outputs. And, of course, searching the array of Strings[] will just find me a useless index.
    My interm solution is this:
    1) pick a small, but likely range of possible values for the ring
    2) iterate through these values, assigning each one in turn to ring
    3) read the RingText property to see if it matches the passed string
    4) if it does, then exit. If it doesn't keep looping.
    5) if no value produces a matching string, declare defeat (raise an error or produce other output that indicates a match could not be found).
    The routine only runs in the UI so I am not too concerned about the time delay this method will i
    mpose, but I would greatly appreciate a smoother solution.
    Thanks for your suggestions.

  • How to find bpel instance in 11g based on the index values using Java APIs

    Hi ,
    In SOA10G we had option to find the instances based on the index value using Java APIs like below.
    WhereCondition criteria= new WhereCondition(SQLDefs.CX_index_1 + " = ?");
    criteria.setString(1, "indexValue");
    Locator mLoc = getLocator();
    IInstanceHandle[] foundInstances = mLoc.listInstancesByIndex(criteria);
    Please tell me how to achieve the same functionality in SOA 11G using Java APIs
    Regards,
    Saba

    I have multiple bpel in my composite. I checked in ci_indexes table and it shows the instance number of the bpel process. But the em console is showing only the composite instance number. when I opened composite instance, I could see all the bpel process with instance number in the audit trail. How can I find the the actual composite instance number that I should search for in the em console ???

  • Where we can find the detail infomation about the Value String of automatic

    Where we can find the detail infomation about the Value String of automatic?
    such as WE06,WE01 and so on.

    Hai,
               Value string keys are for SAP internal usage. It is just a pointer to the transaction event key which is necessary for automatic account determination.
               Movement types are linked to transaction keys via valuation string in OMWN T-code.
               The R/3 System automatically determines the value string assigned to a specific transaction. It depends partly on entered parameters manually and partly on parameters derived internally by the system. The value string contains all posting transactions that are possible for a certain transaction. The program decides which of these posting transactions lead to G/L account postings in individual cases. You cannot define this in Customizing.
    Value string WE01, for the goods receipt for a purchase order into stock, contains transactions BSX and WRX.
    WE01: BSX, WRX, PRD, KDM, EIN, EKG, BSV, FRL, FRN, BSX, UMB.
    WA14: BSX ,PRD, BSX, UMB
    WA01: BSX, GBB, PRD, BSX, UMB
    Value string RE05 contains transactions BSX and UMB.
    In the standard system, value string WE01 is assigned to goods receipts (and also cancellations and return deliveries) for Standard and Subcontracting purchase order items without account assignment concerning valuated material into stock. In the case of (valuated) goods receipts for purchase order items not subject to account assignment,
    post the items to a stock account using the transaction key BSX and make an offsetting entry to a GR/IR clearing account. A price difference posting (transaction key PRD) is only used if the valuated material is subject to standard price control and if the order price (or invoice price) is different from the standard price. Transaction key KDM is required in Inventory Management for purchase orders in foreign currencies because of differences in exchange rates between goods receipts and invoice receipts, unless the material can not be debited or credited because it is subject to standard price control.
    The transaction keys EIN and EKG (and possibly FRE – see account determination for delivery costs) are only used in company codes where purchase account management is active (as required in France and Belgium for example).
    The transaction keys BSV, FRL, and FRN are only used for the Subcontracting item category.
    Value string WA14 is defined for deliveries without charge (movement type 511).
    The following scenarios are possible:
    Delivery without charge for material subject to moving average price control &#8594; No accounting document
    Delivery without charge for material subject to standard price control (and if the posting date is in the previous period – standard price in the posting period = standard price in the current period) &#8594; Inventory posting (receipt at standard price) and offsetting entry to price differences account
    Delivery without charge for material subject to standard price control, with posting date in the previous period and the standard price in the posting period is different to the standard price in the current period &#8594; Inventory posting (receipt at standard price) and offsetting entry to price differences account (posting in the previous period) &#8594; Stock correction posting and Revenue/expense from revaluation (posting in the current period)
    In the standard system, value string WA01 is assigned to goods issues and other goods receipts. The R/3 System uses an additional influencing factor, account grouping, to differentiate further between the various movements during account determination.
    Hope it will be Helpful 4 u.
    Reward Point if Useful.

  • How to find the last string value in dynamic object?

    Hi All,
    I am trying to find the last string value in dyanamic objects,Any one have solution for this.
    Ex:
    my data :12347-ebjdone-525-ecgfjf-25236-defdafgdeg
    And i want to show the output is :defdafgdeg
    Any ideas:
    Thanks
    Srini

    For oracle try using oracle function.
    e.g.
    SELECT  reverse(substr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),1,instr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),'-','1'))) from dual
    Object definition might look like:
    reverse(substr(reverse({ObjectName}),1,instr(reverse({ObjectsName}),'-','1')))
    Regards,
    Kuldeep
    Edited by: Kuldeep Chitrakar on Feb 12, 2010 8:12 AM

  • Finding the multiple indexes of a same value

    Hi
    I have one query,i have 2 main arraylists one arraylist consists of all the indexvalues with the duplicate values and another arraylist consists all the index values without duplicate values.now if i want to find an index of a specified indexvalue from the duplicate arraylist how can i perform,,, here is the example
    MAIN chkList size IS HERE::::::::100
    MAIN chkList IS HERE::::::::[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1
    5, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 14, 15, 16, 17, 18, 19, 2
    0, 5, 6, 21, 22, 23, 24, 25, 1, 2, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11,
    12, 13, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5,
    6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
    uniqueIndexList size IS HERE::::::::100
    uniqueIndexList IS HERE::::::::[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1
    4, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 3
    4, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 5
    4, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 7
    4, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 9
    4, 95, 96, 97, 98, 99]
    for example in the above if you see the value 24 in MAIN chkList it is repeating 4 times... but i wanted to keep this into a new arraylist like it should be arraylist of arraylist like if i request 24 from the new arraylist then i should get the all the indexvalues list for that search criteria.
    how can i do this,plz help me,i am new to this
    regards
    rao

    Tell us more. What ideas have you had yourself? What do you think is right or wrong about the ideas? Have you tried anything? If so, tell us, provide the code if it's not too voluminous, even if it's far from working. Noone can guide you if all we know about where you stand is "i am new to this".

  • How to find bpel instance in 11g based on the index values

    We have 10g BPEL process where we define 4 index values for all the instances. Whenever support request comes, we ask index values and based on that we search the process instance.
    We have migrated this 10g bpel process to 11g now. How to find bpel instance in 11g based on the index values ???

    I have multiple bpel in my composite. I checked in ci_indexes table and it shows the instance number of the bpel process. But the em console is showing only the composite instance number. when I opened composite instance, I could see all the bpel process with instance number in the audit trail. How can I find the the actual composite instance number that I should search for in the em console ???

  • How do i find the length of a string??

    trying to use the substring, I know the beginIndex (in my case 10), but the string will vary in size and so i need to find the last character and set it as the endIndex, how do i do this?
    public String substring(int beginIndex,
    int endIndex)Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
    Examples:
    "hamburger".substring(4, 8) returns "urge"
    "smiles".substring(1, 5) returns "mile"
    Parameters:
    beginIndex - the beginning index, inclusive.
    endIndex - the ending index, exclusive.
    Returns:
    the specified substring.

    Hi
    To substring the string where u know the begin index and want to extract till the end use the following function from the String class of the java.lang package
    String substring(int beginindex);
    String test = "Hello";
    String xx = test.substring(1);
    The Value stored in xx will be ello
    This is in case u need till the end of the String
    If wanna skip the last character u can
    use
    String substring(int beginindex,int endindex);
    String test = "Hello";
    String xx = test.substring(1,test.length()-1);
    The Value stored in xx will be ell

Maybe you are looking for

  • Problem with Dates in the Web Intelligence

    Hello Everyone, I am facing a problem with the Web Intelligence Report, in the universe there is a Date field (L01 Date and L01 Date Key). In the report Web Intelligence when i use L01 Date Key it works fine (like 10/07/2010), but when i use L01 Date

  • How to manage variable conversion factor in UOM to order unit

    Hi, We have a material whose base unit is PC unit price is 8 Euro / PC Order unit is Box now we do not have a standard conversion factor. Means sometimes vendor send 8 pc/ Box ,10 pc /Box and 12 pc /Box so when we create Material master and enter ord

  • Which apple display to get?

    I am thinking of getting a 2nd display for use with my iMac. It's a mid-2010 27" iMac, so it doesn't have Thunderbolt. Apple is selling both a refurbished 27"LED display and Thunderbolt display for the same amount. Other than the possibility of compa

  • Unable to Migrate WCS Database to NCS with Demo License

    I have NCS 1.1.0.58 running on a VM with a demo license, should I be able to migrate my WCS 7.0.230.0 database to NCS?  I can not tell if the  migration process worked and there are no objects in NCS.  I have attached a console capture of the migrati

  • Veiwing mailbox sizes in exchange 2007

    Is it me or is Exchange 2007 missing mailbox size? i cant anywhere to veiw the size of a users mailbox.