Removing leading and trailing delimiters from a String

I need to remove leading and trailing delimiters from a String like if my string is 111,112, then it should get changed to 111,112.Any idea how to do this??

for my suggestion:String s = "111,112,";
int begin = 0;
while (!Character.isLetterOrDigit(s.charAt(begin)))
     begin++;
int end = s.length() - 1;
while (!Character.isLetterOrDigit(s.charAt(end)))
     end--;
String news = s.substring(begin, end + 1);Of course, you'll have to clean it up a bit.

Similar Messages

  • Removing Leading And trailing Zeros

    Hi Guys ,
    Can You help me out in UDF for removing leading and Trailing zeros
    Ex :  0123.234000000
    And it must satisfy below conditions .
    1 ) If value as Null we need 0.0 in target
    2) if the value is 0.0 we need 0.0 in target
    Thanks in Advance

    One more option:
    Input will be "str" of type string.
    Execution type: single value.
    mapping:
    Input -> mapwithdefault(0.0)->UDF->output
    if( !str.equals("0.0"))
    char[] chars = str.toCharArray();
    for (int index=0; index < str.length();index++)
    if (chars[index] != '0')
    str =str.substring(index);
    break;
    int length,index1 ;
    char[] chars1 = str.toCharArray();
    length = str.length();
    index1 = length -1;
    for (int in1=index1-1; in1>0;in1--)
    if (chars1[in1] != '0')
    str=str.substring(0,in1+1);
    break;
    return str;
    else
    return "0.0";
    http://wiki.sdn.sap.com/wiki/display/Java/RemoveLeadingandTrailingZerosfroma+String

  • REGEXP_REPLACE removing leading and trailing quotes.

    Hello guys,
    I have an issue with my regular expression and I'm hoping that someone can help me with it?
    Imagine the following sample_data:
    {code}
    WITH sample_data AS
    SELECT '''[email protected]''' as e FROM dual UNION ALL
    SELECT '''[email protected]' as e FROM dual UNION ALL
    SELECT '[email protected]''' as e FROM dual UNION ALL
    SELECT '''[email protected]''' as e FROM dual UNION ALL
    SELECT '[email protected]''' as e FROM dual UNION ALL
    SELECT '''[email protected]' as e FROM dual
    SELECT e, REGEXP_REPLACE(e, '(^'')?(.*)(''$)', '\2')
      FROM sample_data;
    {code}
    I would like to remove all leading and trailing quotes from the address email. I did the previous regexp but it does not returns the correct result. I don't know why, but for some reasons, when my email does not ends with a quote, the leading quote is not removed.
    Can anyone help me with this?
    Thanks,

    Cant you just trim it?
    WITH sample_data AS
    SELECT '''[email protected]'''      as e FROM dual UNION ALL
    SELECT '''[email protected]'        as e FROM dual UNION ALL
    SELECT '[email protected]'''        as e FROM dual UNION ALL
    SELECT '''[email protected]''' as e FROM dual UNION ALL
    SELECT '[email protected]'''   as e FROM dual UNION ALL
    SELECT '''[email protected]'   as e FROM dual
    SELECT e, rtrim(ltrim(e, ''''), '''') new_e
      FROM sample_data;

  • Remove leading and trailing puncation

    What's the best way to remove leading/trailing puncation from a word? Trim is good for leading and trailing whitespace but can I do anything for leading and trailing punctuation. I need punctuation that's in the middle of a word.

    one way would be to create an array of characters that include all the common punctuation marks. Then, using an iterative loop, compare each char in the file with each char from the array. If a match is found, then the file char is punctuation.

  • Apex: Removing leading and trailing blanks

    Hi,
    when observing end users working with my little apex application I noticed the input of leading and trailing blanks in a report search field. What do you recommend for removing this undesired input?
    I tried an ltrim(rtrim(:p1_searchfield)) in the report SQL query - the result is fine.
    But I have not found a way to keep the higlighting of the search word in the result set. There is a "highlight" property in the report field attributes dialog. But it looks like there is no way to enter any trim funtion over there. So the highlighting of matches does not work if there is a leading or trailing blank.
    Any ideas?
    Thanks & Cu
    Walter

    Walter,
    I would use an "after submit" computation on :p1_searchfield
    trim(:p1_filter)This way you won't have to change your select statement and the highlight term.
    ~Dietmar.

  • Conversion failed when converting date and/or time from character string

    Hi experts,
    I'm trying running a query in Microsoft Query but it gives the following error message:
    "conversion failed when converting date and/or time from character string"
    when asks me the data I'm inserting 31-01-2014
    i've copy the query form the forum:
    SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
         CASE  WHEN T0.TransType=13 THEN 'Invoice'
              WHEN T0.TransType=14 THEN 'Credit Note'
              WHEN T0.TransType=30 THEN 'Journal'
              WHEN T0.TransType=24 THEN 'Receipt'
              END AS 'Document Type',
         T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
    FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    WHERE (T0.MthDate IS NULL OR T0.MthDate > ?) AND T0.RefDate <= ? AND T1.CardType = 'C'
    ORDER BY T1.CardCode, T0.DueDate, T0.Ref1

    Hi,
    The above error appears due to date format is differnt from SAP query generator and SQL server.
    So you need convert all date in above query to SQL server required format.
    Try to convert..let me know if not possible.
    Thanks & Regards,
    Nagarajan

  • Error "Conversion failed when converting date and/or time from character string" to execute one query in sql 2008 r2, run ok in 2005.

    I have  a table-valued function that run in sql 2005 and when try to execute in sql 2008 r2, return the next "Conversion failed when converting date and/or time from character string".
    USE [Runtime]
    GO
    /****** Object:  UserDefinedFunction [dbo].[f_Pinto_Graf_P_Opt]    Script Date: 06/11/2013 08:47:47 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE   FUNCTION [dbo].[f_Pinto_Graf_P_Opt] (@fechaInicio datetime, @fechaFin datetime)  
    -- Declaramos la tabla "@Produc_Opt" que será devuelta por la funcion
    RETURNS @Produc_Opt table ( Hora datetime,NSACOS int, NSACOS_opt int)
    AS  
    BEGIN 
    -- Crea el Cursor
    DECLARE cursorHora CURSOR
    READ_ONLY
    FOR SELECT DateTime, Value FROM f_PP_Graficas ('Pinto_CON_SACOS',@fechaInicio, @fechaFin,'Pinto_PRODUCTO')
    -- Declaracion de variables locales
    DECLARE @produc_opt_hora int
    DECLARE @produc_opt_parc int
    DECLARE @nsacos int
    DECLARE @time_parc datetime
    -- Inicializamos VARIABLES
    SET @produc_opt_hora = (SELECT * FROM f_Valor (@fechaFin,'Pinto_PRODUC_OPT'))
    -- Abre y se crea el conjunto del cursor
    OPEN cursorHora
    -- Comenzamos los calculos 
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    /************  BUCLE WHILE QUE SE VA A MOVER A TRAVES DEL CURSOR  ************/
    WHILE (@@fetch_status <> -1)
    BEGIN
    IF (@@fetch_status = -2)
    BEGIN
    -- Terminamos la ejecucion 
    BREAK
    END
    -- REALIZAMOS CÁLCULOS
    SET @produc_opt_parc = (SELECT dbo.f_P_Opt_Parc (@fechaInicio,@time_parc,@produc_opt_hora))
    -- INSERTAMOS VALORES EN LA TABLA
    INSERT @Produc_Opt VALUES (@time_parc,@nsacos, @produc_opt_parc)
    -- Avanzamos el cursor
    FETCH NEXT FROM cursorHora INTO @time_parc,@nsacos
    END
    /************  FIN DEL BUCLE QUE SE MUEVE A TRAVES DEL CURSOR  ***************/
    -- Cerramos el cursor
    CLOSE cursorHora
    -- Liberamos  los cursores
    DEALLOCATE cursorHora
    RETURN 
    END

    You can search the forums for that error message and find previous discussions - they all boil down to the same problem.  Somewhere in your query that calls this function, the code invoked implicitly converts from string to date/datetime.  In general,
    this works in any version of sql server if the runtime settings are correct for the format of the string data.  The fact that it works in one server and not in another server suggests that the query executes with different settings - and I'll assume for
    the moment that the format of the data involved in this conversion is consistent within the database/resultset and consistent between the 2 servers. 
    I suggest you read Tibor's guide to the datetime datatype (via the link to his site below) first - then go find the actual code that performs this conversion.  It may not be in the function you posted, since that function also executes other functions. 
    You also did not post the query that calls this function, so this function may not, in fact, be the source of the problem at all. 
    Tibor's site

  • SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)

    SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)
    SELECT    
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO AS T0 LEFT OUTER JOIN
                          VPM2 AS T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
         OVPM AS T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1 AS T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

    Hi,
    Try this:
    SELECT   
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO  T0 LEFT OUTER JOIN
                          VPM2  T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry
    LEFT OUTER JOIN
         OVPM  T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1  T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate >= '[%0]' and T0.DocDate <='[%1]'
    group by T0.DocStatus,T0.DocDate ,
    T0.DocNum ,
    T0.NumAtCard,
    T0.TransId ,
    T0.Comments ,
    T0.CardCode,
    T0.CardName ,
    T0.WTSum ,
    T3.DueDate ,
    T3.CheckSum
    Thanks & Regards,
    Nagarajan

  • Unix Flat File: Remove header and trailer and put in another file.

    Hi,
    I have Source Flat File placed on Unix Box with header and trailer.
    I want to remove Header and Trailer and put in some other file and Data in another file.
    I tried following command in unix its working.But not getting Header and Trailer in another file.
    sed '1d;$d' input_source.txt > output_data.txt
    also How will i use OS command for it in ODI.
    Guide me.
    Thanks
    Ashwini

    Hi Ashwini,
    You can run OS commands in a package using an ODI Tool: OdiOSCommand.
    It is also possible to execute OS commands in an ODI procedure using the Operating System or Jython technologies.
    There should be some articles about this on metalink (http://metalink.oracle.com).
    Thanks,
    Julien

  • How do I remove locations and/or pins from maps on iphone 5

    How can I remove locations and/or pins from MAPS?

    A purple pin is a dropped pin. You access that from the "back" of the map, but touching the lower right corner of the map. It is a pin that is dropped in the center of the map you happen to be looking at at the time. If there is no description of the pin, touch the pin and it should show a label, and on the right side of the label there is a blue arrowhead. Touch that and it will provide an address/description of the pin's location and there should be other options, such as directions to here, from here, etc., and then one to remove the pin. Touch that and it should disappear.

  • If I remove itunes and its drivers from my computer, as recommended by someone at the Apple store for a problem I'm having, I know my music will come back, but will my playlists still be there as they are now?

    If I remove itunes and its drivers from my computer, as recommended by someone at the Apple store for a problem I'm having, I know my music will come back, but will my playlists still be there as they are now? I forgot to ask.

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

  • HT201210 How do I remove itune and charger icon from my iphone screen and allow access

    How can I remove itune and charger icon from my iphone 4s screen and allow access. While downloading the lastest version of iune my iphone was being charged. The phone do not allow access anymore.

    Once the Device is asking to be Restored with iTunes... it is too late to save anything... and you must continue with the Recovery...
    Miss Bspace wrote:
    How can I remove itune and charger icon from my iphone 4s screen and allow access. 
    Make sure you have the Current Version of iTunes Installed on your computer
    iTunes free download from www.itunes.com/download
    Then see Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...  Be sure to Follow ALL the Steps...
    Take your time... Pay particular attention to Steps 3 and 4.
    After you have Recovered your Device...
    Re-Sync your Content or Restore from the most recent Backup...
    Restore from Backup  >  http://support.apple.com/kb/ht1766

  • Need to remove photshop and elements 8 from this old win xp computer and install it on new computer. I have the hard copy of the program, howeve registration here may prevent me from re-installing

    how can I remove photoshop and elements 8 from this older computer and install on new computer when it arrives

    You uninstall using the Windows control panel, and you install the same way you did on your old computer... put the disc in the drive and follow the onscreen instructions
    Also, unless you are asking about CLOUD programs, you will do better in the specific program forums
    Photoshop General Discussion
    Community: Premiere Elements | Adobe Community
    Photoshop Elements Forum http://forums.adobe.com/community/photoshop_elements

  • [svn:osmf:] 14178: PARB changes: Remove unload and query methods from PluginManager.

    Revision: 14178
    Revision: 14178
    Author:   [email protected]
    Date:     2010-02-15 21:35:12 -0800 (Mon, 15 Feb 2010)
    Log Message:
    PARB changes: Remove unload and query methods from PluginManager.  We lack compelling use cases for those methods, but can easily re-add them later if we come across some.
    Modified Paths:
        osmf/trunk/apps/samples/framework/DynamicStreamingSample/src/DynamicStreamingSample.mxml
        osmf/trunk/apps/samples/plugins/AkamaiPluginSample/src/AkamaiPluginSample.mxml
        osmf/trunk/apps/samples/plugins/CaptioningSample/src/CaptioningSample.mxml
        osmf/trunk/framework/OSMF/org/osmf/events/PluginManagerEvent.as
        osmf/trunk/framework/OSMF/org/osmf/plugin/PluginManager.as
        osmf/trunk/framework/OSMFIntegrationTest/org/osmf/plugin/TestPluginManagerIntegration.as
        osmf/trunk/framework/OSMFTest/org/osmf/plugin/TestPluginManager.as
        osmf/trunk/plugins/CaptioningPluginTest/src/CaptioningPluginTest.mxml

  • Removing non-alpha-numeric characters from a string

    How can I remove all non-alpha-numeric characters from a string? (i.e. only alpha-numerics should remain in the string).

    Or even without a loop ?
    Extract from the help for the Search and Replace String function :
    Right-click the Search and Replace String function and select Regular Expression from the shortcut menu to configure the function for advanced regular expression searches and partial match substitution in the replacement string.
    Extract from the for the advanced search options :
    [a-zA-Z0-9] matches any lowercase or uppercase letter or any digit. You also can use a character class to match any character not in a given set by adding a caret (^) to the beginning of the class. For example [^a-zA-Z0-9] matches any character that is not a lowercase or uppercase letter and also not a digit.
    Message Edité par JB le 05-06-2008 01:49 PM
    Attachments:
    Example_VI_BD4.png ‏2 KB

Maybe you are looking for