Cut Substring from a string

Hi!
I have a question
Can i cut a substring from a string?
If yes how is possible?
Can you help me with an example?
Thanks

Hi!
I have a question
Can i cut a substring from a string?Yes
If yes how is possible?You shoould read the API for String, there is a method called substring
Can you help me with an example?You wont need one if you read the API

Similar Messages

  • How to get First Occurnece of SubString from any string using SharePoint Designer Workflow in SharePoint Online 2013(Office 365)

    Hello All,
    I am facing Problem in SharePoint Designer Workflow. The Problem is that while replacing some subtstring with Space from a string which contains item like {Test, Test, Test, Test}, It replaces all items.
    Below two line we are using in Workflow.
    Can any body suggest some soultion for Finding first ouucrence of ", " so that we can replace only first value from string not all. When String values are different then getting proper values but if String values are same with comma
    seperated then it replace all values.
    Please some body help and your help will be heighly appriciable.
    Thanks in Advance.
    Thanks,
    Vivek Kumar Pandey   

    Have you tried to use Regular Expressions instead of Replace?
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • What's the best way to extract data (a substring) from a string?

    Hi,
    I have a field being returned from a function call and the data looks like this:
    sfaqwe4|89uuuroeoi0|kjg3j90493  (It's data...pipe...data...pipe...data)
    What is the best technique to use to extract the middle set of data between the two pipes?
    Is the any prewritten method to separate the data, or do I have to loop thru the field looking for the pipes, etc.?
    Thanks for your help,
    Andy

    <<Copy paste from http://careerabap.blogspot.com/2009_08_01_archive.html - user notified, points removed>>
    Hi,
    The WRITE statement is what we use to substring a field. The syntax is as follows:
    WRITE fieldname+starting_position(field_length) to variable
    The fieldname is the source (or input). The plus sign precedes the starting position of the substring.  The first position in the string is 0. Immediately after (no space) comes the length of the substring you are going to use. You can also substring the variable that you are writing the string to (the target).
    You can also use function module 'STRING_SPLIT_AT_POSITION'.
    Best Regards,
    Edited by: nihad omerbegovic on Dec 14, 2009 3:03 PM
    Edited by: Matt on Dec 20, 2009 4:13 PM

  • Deleting leading substring from a string

    Hey guys,
    how can i delete a string from a leading substring?
    e.g.: "00022521" should become "22521".
    thx
    Markus

    I actually had written a little static class to handle just this.  Here is the static class.
    public class LeadingZeroRemover {
         public static String removeLeadingZeros(String str) {
              if (str == null) {
                   return null;
              char[] chars = str.toCharArray();
              int index = 0;
              for (; index < str.length(); index++) {
                   if (chars[index] != '0') {
                        break;
              return (index == 0) ? str : str.substring(index);
    Then you can simply use it like this.
    <b>LeadingZeroRemover.removeLeadingZeros</b> (soldToNumber.getValue().toString())
    Regards,
    Rich Heilman

  • How to extract substring from a string based on the condition ??

    Hi,
    I'm having a very large string which as below
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD'
    FTX+AAA+++ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND'
    FTX+AAA+++IS FAIR'
    similarly FTX+AAA as above and it goes on
    i tokenized each segment with delimiter as ' and able to read each segment.
    Now i want to concatenate the FTX+AAA in a single segment if more than one FTX+AAA with IMMEDIATE below
    The output is as follows
    EQD+CN+SAMPLE18767+2200+++5'
    NAD+CA+FIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++GOOD,ONE'
    EQD+CN+SAMPLE18795+2200+++5'
    NAD+CA+TIR:172:20'
    DGS+IMD+3.2+2346+55:CEL'
    FTX+AAA+++SECOND,IS FAIR'
    similarly FTX+AAA should be concatenated if it has similar FTX+AAA IMMEDIATE below.
    The FTX+AAA segments can come any number of times immediate below
    Please help me how we can do this??? Can anyone help me with the code snippet to do this?
    Thanks,
    Kathir

    Encephalopathic wrote:
    You've posted > 300 times here and you still don't respect the rule regarding notification of all cross-posts? [http://www.java-forums.org/advanced-java/30061-how-extract-substring-string-based-condition.html]
    Do you think this this will help convince others to help you?See also [http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition|http://www.coderanch.com/t/500088/java/java/extract-substring-string-based-condition].

  • HOw to get  a common substring from two strings.

    Hello,
    I have a question like..how to print a common substring in to different strings.
    example: String str1="dynamic" String str2="programing" so the output for this application is "am".

    If the OP is looking for the 'longest common substring', have a look
    here for a nice explanation of Ukkonen's online suffix tree construction.
    A suffix tree is the ideal data structure for finding a LCS.
    kind regards,
    Jos

  • How to get substring from a string?

    For example, there is a string:
    C-REVF-00003 0010 Development
    how the program get the value '0010'?

    Hi,
    Use Split command.
    Syntax
    SPLIT <c> AT <del> INTO <c1>... <cn> INTO TABLE <itab>.
    Searches the field <c> for the character <del> and places the partial fields before and after <del>
    into the target fields <c1> … <cn>, or into a new line of the internal table <itab>.
    Ex.
    DATA: STRING(60),
    P1(20) VALUE '++++++++++++++++++++',
    P2(20) VALUE '++++++++++++++++++++',
    P3(20) VALUE '++++++++++++++++++++',
    P4(20) VALUE '++++++++++++++++++++',
    DEL(3) VALUE '***'.
    STRING = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.
    WRITE STRING.
    SPLIT STRING AT DEL INTO P1 P2 P3 P4.
    WRITE / P1.
    WRITE / P2.
    WRITE / P3.
    WRITE / P4.
    The output appears as follows:
    Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5
    Part 1
    Part 2
    Part 3
    Part 4 *** Part 5
    Regards,
    Bhaskar

  • Finding substring from string.

    I'll have to find substring from another string. Substring to find can be example: CVB and the string can be example ACHGVNB.
    Give me some hints about what methods I should use.

    Like this:public class Test {
        public static void main (String[] parameters) {
            String sub;
            String text;
            if (parameters.length == 2) {
                sub = parameters[0];
                text = parameters[1];
            } else {
                sub = "levi_h";
                text = "l e v i _ h";
            System.out.println (isSub (sub, text));
        private static boolean isSub (String sub, String text) {
            int s = 0;
            int t = 0;
            while ((s < sub.length ()) && (t < text.length ())) {
                if (sub.charAt (s) == text.charAt (t)) {
                    s ++;
                t ++;
            return s == sub.length ();
    }Kind regards,
    Levi

  • Looking for a substring within a string (regexp)

    Hi folks,
    I want to select a substring from a string
    string:
    21;0000;4145054;4;A;4 mit ALU XEOFX,117107,XEOFX YWY,1,YWY
    or
    21;0000;4145054;4;A;4 goldglamsnu XEOFX,198877,XEOFX YWY,1,YWY
    I'm looking for the substring:
    YWY,1,YWY
    and try this SQL statement
    SQL> select REGEXP_substr('21;0000;4145054;4;A;4 mit ALU XEOFX,117107,XEOFX YWY,1,YWY' ,',[^YWY]+[0-9]')
    2 from dual;
    REGEXP_
    ,117107
    I don't know where my mistake is. Can anybody please help me?
    Database Version 11G R2
    Thanks,
    ben
    Edited by: ben512 on May 14, 2013 5:05 PM

    Hi,
    ben512 wrote:
    Hi folks,
    I want to select a substring from a string
    string:
    21;0000;4145054;4;A;4 mit ALU XEOFX,117107,XEOFX YWY,1,YWY
    or
    21;0000;4145054;4;A;4 goldglamsnu XEOFX,198877,XEOFX YWY,1,YWY
    I'm looking for the substring:
    YWY,1,YWYWhy do you want that substring. Do you always want the last 9 characters of the string?
    If you're looking for a substring that starts with 'YWY', and then has any number (including 0) of commas, digits, and additional 'YWY' strings after it, then:
    REGEXP_SUBSTR ( str
               , 'YWY[,[:digit:]]*)
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, maybe 5 or 10 rows), and also post the results you want from that data. Include examples of any special cases you need to handle (e.g., the target pattern is not found at all, or it is found at 2 different places in the string).
    Explain, using specific examples, how you get those results from that data. Say what your business rules are.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • How to extract substring from string... how to find the index?

    suppose i have a string like
    "string1 string2 string3 string4 string....stringK...stringN"
    i would like to extract the substring from string4 to stringK-1
    where stringK and string3 are pre defined strings (ie, i know exactly what stringK and string3 is).
    is there a function to extract the substring from string4 to stringK-1
    or is there a function i can use to determine the index of the end of string4 and the start of stringK?
    thks!

    If your substrings are seperated by a space (or by any other character that isn't used in any of the substrings), you could use something like StringTokenizer.
    If you wanna get real fancy, use the split method of String.

  • Cut text from string

    Hello. Is there any way I can cut text from string?
    I have responseResult variable which has value: {"success":true,"error":"No any errors."}
    I want >>No any errors. << text from that string variable.

    Like Varun suggested above, this text is JSON, and you can parse out the various values using JSON deserialising.
    If you just want to use standard string manipulation (which I wouldn't recommend unless this is the only string you want to 'cut up') you can use various combinations of string functions.
    For example, you could split the string at every double-quote mark:
    string jsonString = "{\"success\":true,\"error\":\"No any errors.\"}"; // initial string
    string[] strParts = jsonString.Split('\"'); // split string into an array of parts of the original separated at each double quote symbol
    string partINeed = strParts[5]; // get the specific part needed
    That's not a good way to do this in general (you should add proper JSON parsing), but for a single use it's OK. Note that you have to hard-code which piece of the string you're getting, which is not a safe approach.
    Also note I used "\" in those strings so I could incorporate double-quotes in the string.
    For more detailed string manipulation read up on RegEx. If you need to parse a lot of these strings in your app use JSON.
    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.
    Thank you guys. That solved my problem.

  • Removing characters from a String (concats, substrings, etc)

    This has got me pretty stumped.
    I'm creating a class which takes in a string and then returns the string without vowels and without even numbers. Vowels and even characters are considered "invalid." As an example:
    Input: "hello 123"
    Output: "hll 13"
    The output is the "valid" form of the string.
    Within my class, I have various methods set up, one of which determines if a particular character is "valid" or not, and it is working fine. My problem is that I can't figure out how to essentially "erase" the invalid characters from the string. I have been trying to work with substrings and the concat method, but I can't seem to get it to do what I want. I either get an OutOfBoundsException throw, or I get a cut-up string that just isn't quite right. One time I got the method to work with "hello" (it returned "hll") but when I modified the string the method stopped working again.
    Here's what I have at the moment. It doesn't work properly for all strings, but it should give you an idea of where i'm going with it.
    public String getValidString(){
              String valid = str;
              int start = 0;
              for(int i=0; i<=valid.length()-1; i++){
                   if(isValid(valid.charAt(i))==false){
                             String sub1 = valid.substring(start, i);
                             while(isValid(valid.charAt(i))==false)
                                  i++;
                             start=i;
                             String sub2 = valid.substring(i, valid.length()-1);
                             valid = sub1.concat(sub2);
              return valid;
         }So does anybody have any advice for me or know how I can get this to work?
    Thanks a lot.

    Thansk for the suggestions so far, but i'm not sure how to implement some of them into my program. I probably wasn't specific enough about what all I have.
    I have two classes. One is NoVowelNoEven which contains the code for handling the string. The other is simply a test class, which has my main() method, used for running the program.
    Here's my class and what's involved:
    public class NoVowelNoEven {
    //data fields
         private String str;
    //constructors
         NoVowelNoEven(){
              str="hello";
         NoVowelNoEven(String string){
              str=string;
    //methods
         public String getOriginal(){
              return str;
         public String getValidString(){
              String valid = str;
              int start = 0;
              for(int i=0; i<=valid.length()-1; i++){
                   if(isValid(valid.charAt(i))==false){
                             String sub1 = valid.substring(start, i);
                             while(isValid(valid.charAt(i))==false)
                                  i++;
                             start=i;
                             String sub2 = valid.substring(i, valid.length()-1);
                             valid = sub1.concat(sub2);
              return valid;
         public static int countValidChar(String string){
              int valid=string.length();
              for(int i=0; i<=string.length()-1; i++){
                   if(isNumber(string.charAt(i))==false){
                        if((upperVowel(string.charAt(i))==true)||lowerVowel(string.charAt(i))){
                             valid--;}
                   else if(even(string.charAt(i))==true)
                        valid--;
              return valid;
         private static boolean even(char num){
              boolean even=false;
              int test=(int)num-48;
              if(test%2==0)
                   even=true;
              return even;
         private static boolean isNumber(char chara){
              boolean number=false;
              for(int i=0; i<=9; i++){
                   if((int)chara-48==i){
                        number=true;
              return number;
         private static boolean isValid(char chara){
              boolean valid=true;
              if(isNumber(chara)==true){
                   if(even(chara)==true)
                        valid=false;
              if((upperVowel(chara)==true)||(lowerVowel(chara)==true))
                   valid=false;
              return valid;
    }So in my test class i'd have something like this:
    public class test {
    public static void main(String[] args){
         NoVowelNoEven test1 = new NoVowelNoEven();
         NoVowelNoEven test2 = new NoVowelNoEven("hello 123");
         System.out.println(test1.getOriginal());
         //This prints hello   (default constructor string is "hello")
         System.out.println(test1.countValidChar(test1.getOriginal()));
         //This prints 3
         System.out.println(test1.getValidString());
         //This SHOULD print hll
    }

  • Retrieve data from a string.

    I want to write a SQL script to retreive data between the third "|" and the forth "|" from a string:
    Example:
    String = 'H000319|VI|12|20000|20000|4201840007403429,09/2008,442667,,|'
    The result should be 20000.
    String = 'H000319|HK|0|11860|11860||'
    The result should be 11860.
    Many thanks!

    With INSTR you can search for the n'th occurence of a character like this:
    select substr('H000319|HK|0|11860|11860||'
                 , instr('H000319|HK|0|11860|11860||', '|', 1, 3 ) + 1
                 , length('H000319|HK|0|11860|11860||') - instr('H000319|HK|0|11860|11860||', '|', 1, 4 ) - 2
                ) from dual

  • Trying to get a date value from a string

    Hi All,
    I'm not sure I am doing this right, so I figured I would ask the experts...
    I have built a file upload page that is working the way I need it, but I have found that I need to determine the date from the uploaded file name. I tried to create a PL/SQL computation and do some substr / instr to the filename, but I'm not getting it as I get "ORA-01843: not a valid month" error. Here is the code I'm trying:
    declare
      v_underscore  integer;
      v_date            varchar2(15);  --have also tried using date datatype...
    begin
      v_underscore := INSTR(:P20_EXPRESS,'_',1,1);
      v_date := to_date(substr(:P20_EXPRESS,v_underscore + 1,6),'YYMMDD');
      return v_date;
    end;And here is a sample filename:
    F15047/proc_10607161001.csv
    Is this the best way to achive what I'm trying to do?
    Thanks,
    Corey

    Hi,
    v_underscore := INSTR(:P20_EXPRESS,'_',1,1);
    v_date := to_date(substr(:P20_EXPRESS,v_underscore + 1,6),'YYMMDD');What this is saying is:
    Get the position of the "_" character
    Move to the next character to the right (which is a "1" in your case)
    Get 6 characters (106071) from the string value
    Convert them to a date using the format 'YYMMDD'
    This results in:
    Year: 10
    Month: 60
    Day: 71
    Which of course is not valid.
    For example:
    select
      substr('F15047/proc_10607161001.csv', instr('F15047/proc_10607161001.csv', '_', 1, 1) + 1, 6)
    from
      dual;
    SUBSTR
    106071It looks like you want to move two positions to the right rather than a single position:
    select
      substr('F15047/proc_10607161001.csv', instr('F15047/proc_10607161001.csv', '_', 1, 1) + 2, 6)
    from
      dual;
    SUBSTR
    060716Hope that helps a bit,
    Mark

  • Splitting and grouping of data from incoming string

    Hello,
    I have a package of data coming from the serial port and read out as a string.
    The package has the following format, to be short.
    1. opening characters
    2. 2 bytes for Group ID(identify the device# the data comes from).
    3. Sensors data belongs to device# (1 byte each)
    -data of sensor #1
    -data of sensor #2
    -data of sensor #3
    -data of sensor #4
    and loop back to sensor 1,2,3,4 for 20 bytes total.
    I have eliminated the opening characters with the replace substring with empty string. For the Group ID, I used a case structure to identify which device it is. For the sensor data, I need to split them up and group all the data of the sensors together. I tried using substring for each sensor in a for loop that loop 5 times to group the data of each sensor together but it only give me the very last values.
    My goal is to be able to extract and group the 5 bytes of each sensor together everytime the serial package comes in and then save them to a separte files for each sensor. I also want to be able to plot the data of each sensor as they come in with respect to time.
    Any idea on how I can accomplish the grouping of data described above? I really appreciate your prompt response. Thanks,

    Since you already know how to separate the sting containing the sensors data, you just have to use a string to byte function and to decimate the resulting array, as shown in the attached vi.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Sensor data.vi ‏39 KB

Maybe you are looking for

  • Adobe photoshop starter edition 3.2 help

    I have this program on my computer. I tried to register, but apparantly I can't because I miss the two months window. Need help to get my pictures out. Called the company direct and they said they can't help me. I was directed here for help. Please a

  • Report on Deviations in 13 weeks or 3 months History data

    Currently we have a deviations in the forecasting for example week 1 has 100 EA and wk2 has 1000 and then wk3 has 110.It's just an example not exact figures but the bottomline is we have large deviations in some weeks. Now the forecaster needs to kno

  • In ALV- Coulmns are jumbling in print preview and word doc.(irregular)

    Hi Gurus, In ALV, i am getting  the output with proper column allignment. But when i click on print preview in the output, columns are jumbling (irregular pattern- not in proper allignment) and also i am pulling the output data in spool throgh PDF fo

  • ABAP and SD

    Hi Friends, I have got a job in functional (SD module). I being a Software engineer have interest in programming . ABAP is what I have heard of as a language used for customization in SAP. Will it make a difference if I stick to SD module for some ti

  • Badi for searchterm and lifecycle

    Hi, When an account is created then the value in searchterm is checked against a table .If the value in searchterm is present in the ztable and our lifecycle value is customer then that account is created otherwise an error message is to be returned