Extracting a string

Hello 
I have a list with content
 Joe DOH (JD:45)
 Chris Jones (CJ:47)
 Angela K. Macon (AKM:38)
How to recover for each item only the name ?, ignoring what is in the brackets.
 Joe DOH 
 Chris Jones 
 Angela K. Macon
Thanks

Assuming that the name doesn't contain any paranthesis you could use the IndexOf method and the Substring method like this:
string text = "Joe DOH (JD:45)";
int index = text.IndexOf(" (");
if(index != -1) {
string name = text.Substring(0, index);
Please remember to close your threads by marking helpful as answer and then start a new thread if you have a new question.

Similar Messages

  • How to extract sub string value from a string?

    Hi,
    I need to know how can i extract sub strings from a main
    string, something like this:
    main variable-------->"2087-5E2SE-19-JG7BC"
    i want to split it into like this:
    sub_main_1 variable---------> "2087"
    sub_main_2 variable---------> "5E2SE"
    sub_main_2 variable---------> "19"
    sub_main_2 variable---------> "JG7BC"
    I did the same in flash by using Split and arrays, like this:
    var my_str:String = "2087-5E2SE-19-JG7BC";
    var my_array:Array = my_str.split("-");
    for (var i = 0; i<my_array.length; i++) {
    trace(my_array
    this.aaa1 = my_array[1];
    this.aaa2 = my_array[2];
    this.aaa3 = my_array[3];
    this.aaa4 = my_array[4];
    My question is that how can i do the same in director ?? i
    haven't find any split function in director.
    Thanks in advance,
    Amir

    You do a similar thing in Director using the itemDelimiter,
    which is a
    _player object property in MX2004. By default, it's a comma:
    put _player.itemDelimiter
    It will let you get specific items within a string.
    p = "2087-5E2SE-19-JG7BC"
    _player.itemDelimiter = "-"
    put p.item[1]
    -- "2087"
    You could use it to write yourself a little split function:
    on split(theString, theDelimiter)
    oldDelim = _player.itemDelimiter
    _player.itemDelimiter = theDelimiter
    itemList = []
    repeat with cnt = 1 to theString.item.count
    itemList.add(theString.item[cnt])
    end repeat
    return itemList
    end
    p = "2087-5E2SE-19-JG7BC"
    a = split(p, "-")
    put a
    -- ["2087", "5E2SE", "19", "JG7BC"]
    Dave -
    Adobe Community Expert
    www.blurredistinction.com
    http://www.adobe.com/communities/experts/

  • Subject: extract the string before space

    I have a string say "aquarium a". i want to extract the string appearing before the space and discard the string appearing after space.
    that is the resultant string required is "aquarium". any number of characters can appear after space.
    is it possible to solve using replace() method. i cant hardcode space+character in replace method because number of characters after space is not known.
    Is there any easy way to get the required result

    > i want to check if a string has space in between then
    only this code should run otherwise this code should
    not run. because if a string doesn't have any space
    inbetween then the above code will give error.
    String s = "aquarium a";
    s = s.split("\\s")[0];
    assert s.equals("aquarium");At this point, it would be a good idea to familiarize yourself with the String API. That way, you'll have a better idea how to accomplish your specific requirements.
    ~

  • Data extraction from string

    I'm trying to search a particular value in a string file. The string contains many parameters followed by their values and units. I want to identify and extract, as a number, the value of a particular parameter. The program will basically ask the user to type in (or select from a list of given) parameters in a dialogue box. Then it should display the value of the parameter.
    The string I'm trying to work with, is of the form:-
    SensorOneInMM,34585
    BatteryVoltageInmV,19761
    BattTemp1InC,20
    CliffDistanceLeftInMM,60
    CliffDistanceRightInMM,60
    RightSensor,0
    LeftSensor,0
    CurrentInmAforMotor, 789
    TestingCurrentInmA, 123
    Temp1InC,28
    Temp2InC,28
    BaseCurrentInmA,1342
    ChargeInmV,218
    CurrentInmA,9999
    NotConnected3,0
    Now, for example the value I want to read is the one in Blue color. But the expression, "CurrentInmA" appears several times, in the string. How can I identify the value of the parameter in Blue color??
    Thanks for helping out an amateur!!!
    Cheers.

    Rajat
    I think  you want to extract the value from specific string..
    you can get number of post releted to your question...few are follow
    Post 1
    Post2
    also see attached vi which specific to your problem..
    Attachments:
    Extract frm string.png ‏21 KB

  • How can i extract data strings (temp. press. rel.hum etc) using a Virtual interface through an RS-232 connection​?

    How can i extract data strings (temperature, pressure, relative humidity etc) using a Virtual interface through an RS-232 connection?

    Try this.  It is in LV 8.5.
    Note the double % in the format string.  This is so the % in the input string is treated as a percent rather than a code.
    You may also have to work with the line feed characters in case they are different in the string coming in compared to how the string shows up in the web browser.
    Message Edited by Ravens Fan on 02-12-2008 10:19 PM
    Attachments:
    Example_BD.png ‏4 KB
    Untitled 11.vi ‏9 KB

  • Extract numeric string in string

    I want to extract numeric string from astring.
    it should stop reading if it hits an alphabet that is requirement.it is not that numeric string is of fixed lenght but it will be in begining.
    example:78965rocksalt
    result:78965.

    Hi,
    use fm PREPARE_STRING
    DATA zahl(11) VALUE ' 0123456789'.
        CALL FUNCTION 'PREPARE_STRING'
             EXPORTING
                  i_valid_chars  = zahl
                  i_xvalid_check = 'X'
                  i_xchar_repl   = 'X'
                  i_xtoupper     = 'X'
             CHANGING
                  c_string       = example.
        CONDENSE example NO-GAPS.
        result = example.
    Andreas
    pls reward useful answers
    thank you

  • SQL Extract Variable String in Variable Position with Variable length from ntext field

    i want to extract a variable string from an ntext field. 
    Sample Data in Background_text (ntext)
    function changeFocus()  {         document.getElementById('skipContent').style.visibility = 'visible';         document.getElementById('flashContent').blur();        
    document.getElementById('skip').focus();  }  </script>    </head>  <body onload='hideDiv()'>    <div id="flashContent" align="center">     <object
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="440" id="Animation" align="middle">      <param name="movie"
    value="/assets/abc/images/abcdef.swf" />      <param name="quality" value="high" />
    I want to extract this data:      "/assets/abc/images/abcdef.swf"
    The string will always be preceded by value="     AND end in
    .swf"
    As a first attempt, I tried
    SELECT SUBSTRING([Background_text], CHARINDEX('value="/assets/', [background_text]) + 15, LEN(convert(varchar(max), background_text) -
    CHARINDEX('value="/assets/', [Background_text]) + 15) - 1)
    but I received this error
    Msg 245, Level 16, State 1, Line 1
    Conversion failed when converting the varchar value .......  to data type int
    This query won't completely accomplish what I want. Do you have a suggestion?
    Thanks.

    I'd add an extra bit of logic into the expression to only look for 'swf' AFTER the start of the string - it might be that you can guarantee that no occurrence of 'swf' will ever appear in the ntext, but who knows what might change in the future, and it's
    good practice to code defensively.
    SELECT
    SUBSTRING(
    Background_text,
    CHARINDEX('value="/assets/', background_text) + 6,
    CHARINDEX('.swf', SUBSTRING(
    Background_text,
    CHARINDEX('value="/assets/', background_text) + 6,
    LEN(cast(background_text as varchar(max)))
    ) + 4

  • Request help for Extracting CLOB String

    Hi Everyone,
    I am getting the input string in the form of CLOB delimited by '~'. I have to tokenize the string and insert those values into the below table through procedure / function.
    Create table TEST_TEMP ( NUM NUMBER(10),
    NAME VARCHAR2(1000),
    DESCRIPTION CLOB,
    VALIDATION CLOB,
    CREATED_DATE DATE,
    COMPLETED VARCHAR2(1),
    USER NUMBER(3));
    For example the input string would be '11~test~sdfsdfsd~ewrerwerwerw~2007-10-10 13:00:00~Y~123'
    Can you suggest any ideas / links how to do this?
    Thanks

    You can use this select to extract the values:
    michaels>  with test1 as (
      select '11~test~sdfsdfsd~ewrerwerwerw~2007-10-10 13:00:00~Y~123'  str from dual union all
      select '12~test2~sdfsdfsd~ewrerwerwerw~2007-10-11 13:00:00~Y~123'     from dual)
    select t.column_value.extract('s/s[1]/text()').getnumberval()  num,
           t.column_value.extract('s/s[2]/text()').getstringval()  name,
           t.column_value.extract('s/s[3]/text()').getclobval()  description,
           t.column_value.extract('s/s[4]/text()').getclobval()  validation,
           to_date(t.column_value.extract('s/s[5]/text()').getstringval(),'yyyy-mm-dd hh24:mi:ss')  created_date,
           t.column_value.extract('s/s[6]/text()').getstringval()  completed,
           t.column_value.extract('s/s[7]/text()').getnumberval()  "USER"
      from test1, table(xmlsequence(xmltype('<s><s>' || replace(str,'~','</s><s>') || '</s></s>').extract('s'))) t
           NUM NAME  DESCRIPTION      VALIDATION               CREATED_D COMPLETED        USER
            11 test  sdfsdfsd         ewrerwerwerw             10-OKT-07 Y                 123
            12 test2 sdfsdfsd         ewrerwerwerw             11-OKT-07 Y                 123

  • Extracting from String

    Hi,
    if i have a String like 'M[ey]er' how could i extract all information that is not within the brackets so it would give me 'Mer' then ?
    Thanks,

    Hi ,
    Modified <b>...works with string</b> also...
    data:
    w_string type string value 'ram[mohan]hh[rao]kkk[ram]h[nagam]',
    w_len type i,
    w_cnt type i.
    data:
    w_output type string ,
    w_temp type string.
    data:
    itab like standard table of w_string with header line.
    translate w_string to upper case.
    w_len = strlen( w_string ).
    do w_len times.
    w_cnt = sy-index - 1.
    if w_string+w_cnt(1) na sy-abcde.
        concatenate w_temp ']'  into w_temp.
    else.
        concatenate w_temp w_string+w_cnt(1)  into w_temp.
    endif.
    enddo.
    w_string = w_temp.
    split w_string at ']' into table itab.
    loop at itab .
      w_cnt = sy-tabix mod 2.
      if w_cnt eq 1.
        w_len = strlen( itab ).
        if w_len = 1.
          w_temp = '[?]'.
        else.
        w_temp = '[*]'.
        endif.
      else.
        w_temp = itab.
      endif.
      concatenate w_output w_temp into w_output.
      clear w_temp.
    endloop.
      write: w_output.

  • How to extract a string value from a varchar column

    Hi,
    I've a varchar2 column which has got xml data. I want to extract the value of some tag <test></test>
    I can't use EXTRACT as the column is not XMLTYPE.
    Please suggest.

    Hi,
    make a new temporary table table wirth columns as the same name as TAGS in your XML.
    extract the XML in a temporary variable.
    pass it to the below proc with the table name created in step1 , it will populate the temporary table with the XML data.
    PROCEDURE prc_save_xml(
    iv_table_name IN VARCHAR2,
    ic_xmlstring IN CLOB,
    on_count OUT NUMBER,
    ov_remarks OUT VARCHAR2,
    ov_status OUT VARCHAR2,
    iv_row_tag IN VARCHAR2 DEFAULT 'ROW'
    ) IS
    insctx dbms_xmlsave.ctxtype;
    doc CLOB;
    BEGIN
    --Get a context handle
    insctx := dbms_xmlsave.newcontext(iv_table_name);
    dbms_xmlsave.setdateformat(insctx, 'YYYYMMDD');
    dbms_xmlsave.setrowtag(insctx, iv_row_tag);
    ov_remarks := 'Inserting now';
    on_count := dbms_xmlsave.insertxml(insctx, ic_xmlstring);
    ov_remarks := 'Inserted now';
    dbms_xmlsave.closecontext(insctx);
    --set return status as Success
    ov_remarks := 'Sucess';
    ov_status := gv_success;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.put_line('IN OTHERS :' || SQLERRM);
    ov_status := gv_failure;
    ov_remarks := ov_remarks || ':' || SQLERRM;
    on_count := 0;
    END prc_save_xml;

  • Extracting a string from a URL using regular expression

    Given the following expression:
    "^.*" + "http://www\\.xyz\\.gov/class/"+ "([0-9]+)";
    I would expect that if i pass the string "http://www.xyz.gov/class/17950142?dopt=abstract" it should match to everything up to the ? character.
    Why does it not do that in the following code snippet?
    public class RegexTester {
      private final static String EPR_TYPE_1 = "http://www\\.xyz\\.gov/class/";
      public static void main(String args[]){
      String testRegex = "^.*" + EPR_TYPE_1 + "([0-9]+)";
      String testString = "http://www.xyz.gov/class/17950142?dopt=abstract";
      Pattern PATTERN = Pattern.compile(testRegex, Pattern.CASE_INSENSITIVE);
      Matcher m = PATTERN.matcher(testString);
      if(m.matches()) {
      System.out.println(m.group(1));
      }else{
      System.out.println("No match");
    I tried the same expression and string in an online regex tester and it seems to work See example here RegExr

    index4 = line.indexOf( "@photo" );
    String strUid = line.substring(index4,-10);I assumed that index4 would be around 30 as it starts
    at around the 30th character in the string line. And
    then if i wanted the 10 characters preceding this to
    use -10.
    It throws an out of bounds exception thoughIt will as the 2nd parameter is -10 which is before the start of the string
    you need
    String strUid = line.substring(index4 - 10 , index4);

  • How to extract from string

    I know I have done this in CVI before..
    I just can't remember how I did it.. 
    (braindead today???!!!???)
    Here goes:
    Take a string:
    "Mary had a little lamb"
    FindPattern "little"
    resulting string:  ""Mary had a lamb"
    What I have works up to finding the pattern and it's location.
    -sigh-
    I know I'll kick myself because from what I recall, it's a very simple solution... I just can't think of it..
    And I vaguely remember the function name that I used...
    R
    Solved!
    Go to Solution.

    Thanks,
    I should have mentionned that the token in this case is a backspace '\b' character.
    The idea is to remove all backspace characters and the character preceding it.
    R
    Here's a sample of the data:
    [Counting] erozurozefozerczeroberozurozefozerczerobNumber of test Errors: 0

  • How to extract the string part by part

    I have a variable like,
    var := 'c001','c002','c003';
    I want to take c001 c002 and c003 seperately and insert into some table having one column as seperate rows,
    Please let me know how to do that.
    Thnx for ur response.

    Hi
    Are you using any formula to get count ?  if so, you can convert that in text by using
    If count = 1 then totext(count,"0,000")  // to get thousand separator
    If count = then totext(count,"####") to display without thousand separator without dicimal places.
    Now you use this formula in your chart to avoide dicimal places.
    Thanks,
    Sastry

  • 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].

  • Scan from string and extract string between delimiter

    Hello,
    Basic questions.  Is it possible with the scan from string regular expression to extract the string that are within the specified delimiters.  Here is an example:
    \\Name of folder 1\Name of folder 2\Name of folder 3\File Name
    Can the scan from string output the following by specifying the right regular expression:
    Name of folder 1
    Name of folder 2
    Name of folder 3
    File Name
    I have tried \\\\%s\\%s\\%s\\%s but the %s stops at the first white space.
    Thanks,
    Michel
    Solved!
    Go to Solution.

    RavensFan suggested the appropriate function for your requirement, however you can also use an alternative, which is 'Spreadsheet String To Array'.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

Maybe you are looking for

  • Adobe Acrobat 8.0 Standard Download link?

    Can anyone point me to or send me a Adobe Acrobat 8.0 Standard Download link? I cant find one anywhere. I already have my License Keys., Adobe Acrobat 8.0 Standard Download link?

  • Java script not working in Answers

    Hi All, I have a problem with my Narrative report which contains Javascript. I need to show a checkbox (Checked or Unchecked) using a certain condition. This is showing correct output when am doing _"Preview Analysis"_ , but not in the _"Display Resu

  • Using get_AJAX_SELECT_XML causes form to "hang" in IE but notin  FIREFOX

    I have 2 fields on a form that are coordinated to make use of the javascript call of get_AJAX_SELECT_XML, P118_CLONE_DEPT P118_CLONE_POS The HTML form element attributes for P118_CLONE_DEPT are: onchange="get_AJAX_SELECT_XML(this,'P118_CLONE_POS')" T

  • Exit Code 7 error installing trial version of Adobe Captivate 5

    Hi, I am getting an Exit Code 7 error when installing a trial version of Adobe Captivate 5 on an XP SP3 32bit laptop. I have the install logs (i've tried installing a couple of times) but i can't see how to attach the files in this window. Can you he

  • Error when add/ drop new logfile

    When I drop or add new logfile in my 10g r2 on RHEL, I did not see any error. however when I check the alert log file, I noticed at the same time of dropping or adding the logfile, systen produced three error .trc files in the udumpa and display erro