Compare and extract number from string

Hi, all
If I want to compare a requirement number and extract a number form a continuous data, . for example,
the string like this ( ******** 123 ******
                               *********456 ******
                               *********789*******)
and I have requiremnts that I need to extract the number is nearest greater 450, so in the above example, I need to pick 456.
How can I result it?
thanks

Just extract all numbers into an array, then find the element with the smallest absolute difference. See attached (LabVIEW 7.0).
EDIT: Sorry, If by "Nearest greater" you mean the next higher number, you can use something like in my example II. (Also LabVIEW 7.0).
If you don't recognize an node, just right-click on it and select help.
You still need to add proper execption handling, e.g.:
What if no element is greater?
What if there are multiple solutions?
What if the string does not contain any numbers?
Message Edited by altenbach on 10-13-2005 09:05 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
FindClosest.vi ‏29 KB
FindClosestII.vi ‏30 KB

Similar Messages

  • Hyperion Brio: Computed Item Extract Number From String

    I would like to extract a number from a string in a computer item.  For example if I had a string such as "The customer purchased $5.00 of footballs", I would like to remove only the 5.00 from the string.  I would have to use the java functions in the results.  Any suggestions on how to do this?

    you can do this in the Results section with a computed column using the native string functions.  to break it down i have split it up a bit.
    strval is you string "The customer purchased $5.00 of footballs"
    position of $ = 25
         Instr ( strval, '$', 1, 1 )
    the starting position of the amount would then be 26
         Instr ( strval, '$', 1, 1 ) + 1
    position of decimal after $ = 26
         Instr ( strval, '.', Instr ( strval, '$', 1, 1 ), 1 )
    using Substr function you need to pick the string, the start value and the number of characters.
    string
         = strval
    start position
         = Instr ( strval, '$', 1, 1 ) + 1
    number of characters - location of decimal minus the start position plus 3 to get the cents
         = Instr ( strval, '.', Instr ( strval, '$', 1, 1 ), 1 ) - Instr ( strval, '$', 1, 1 )  + 3
    put all together
    Substr( strval, Instr ( strval, '$', 1, 1 ) + 1,  Instr ( strval, '.', Instr ( strval, '$', 1, 1 ), 1 ) - Instr ( strval, '$', 1, 1 )  + 3 ) * 1
    the multiply by 1 converts the string to number

  • More efficient way to extract number from string

    Hello guys,
    I am using this Regexp to extract numbers from a string, and I doubt that there is a more efficient way to get this done:
    SELECT  regexp_replace (regexp_replace ( REGEXp_REPLACE ('  !@#$%^&*()_+= '' + 00 SDFKA 324 000 8702 234 |  " ' , '[[:punct:]]',''), '[[:space:]]',''), '[[:alpha:]]','')  FROM dual
    {code}
    Is there a more efficient way to get this done ?
    Regards,
    Fateh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Or, with less writing, using Perl syntax \D (non-digit):
    SELECT  regexp_replace('  !@#$%^&*()_+= '' + 00 SDFKA 324 000 8702 234 |  " ','\D')
      FROM  dual
    REGEXP_REPLACE(
    003240008702234
    SQL>
    {code}
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Extract Number from string

    I need to extract the number, if it exists, from an alphanumeric text string.  I am told that the first two characters will be alpha and the remaining character(s) will be numeric, if the numeric exists at all.
    I know this is a simple formula, but I can't quite get it.

    Are the two alpha and remaining numeric characters always in the same position within the string?
    Are the two alpha characters always going to be the same?
    Is the length of the numeric value following the two alpha characters always going to be the same?
    The more no answers you have to the above the tougher it will be!
    Get back with the above answers and possibly copy and paste some examples of the ENTIRE strings from which you will be extracting the values and let us know which are the values you'll be pulling from within the larger string.
    "I need to extract the number, if it exists, from an alphanumeric text string. I am told that the first two characters will be alpha and the remaining character(s) will be numeric, if the numeric exists at all.
    I know this is a simple formula, but I can't quite get it."

  • Urgent pl.  I want to extract float from string (%f %s) or (%s %f) separate

    I want to extract float from string (%f %s) or (%s %f) separated by tab, whitespace etc., Since I am using jdk1.3.1 I can't use regular expression can anybody suggest a simple (one or two or few line code - compact) to get the float in (sign+/-)#.#### format ignoring other characters ?
    I tried:
    e.g.,
    String d="4.000 [tab]4";
    source string resulted from "SUBSTRING query of mySQL" can be of :
    " -4.543 XYZ ",
    " XYZ -4.546 ",
    " xx-yy 6.58 3 ",
    "6.0 xxx yyy zzz",
    the expected results for float from the string should be:
    -4.543
    -4.546
    6.580
    6.000
    If String containing data separated by comma:
    e.g.,
    "4.120     1     ,
    AAXXFE     ,4.206     1     ,
         4.000     1,
         4.201     1,
         4.189     1,
         4.204     1,
    S     DDERSF-RSA"
    The result should be: "4.120,4.206,4.000,4.201,4.189,4.204,0.000"
    The string is created by:
    ResultSet rs1 = stmt.executeQuery(S1);
    while (rs1.next()) {  
    String d = rs1.getString("SUBSTRING(FIELD1,LOCATE(\""+s2[i]+"\",FIELD1)+"+ k_st + ","+ length+")");
    System.out.print(d+",");
    May be I don't know how to use the following:
    float f1 = Float.parseFloat(d);
    ===
    String pattern = "###.###";
    //float value = -2100.578f;
    DecimalFormat myFormatter = new DecimalFormat(pattern);
    String output = myFormatter.format(d);
    System.out.println(d+" " + pattern + " " + output);
    ===

    Hi
    You made the best choice. JRegex is closer to java.util.regex.* and fine works with excellent performance in any JVM version so you can use examples/tutorials from both JRegex and Java.Sun.Com to learn more about regular expression.
    About the regular expression in my last post, there are two capturing groups: the first for float numbers in IEEE format specification (also see Java Language Specification) and the second for any sequence of chars, groups using with any amount of blank spaces (spaces, tabs, etc :: see regular expression definition) as delimiter. The anchors "^" and "$" are being used to exactly match pattern in target string and you can relax this constraint as needed.
    How to use JRegex? no secrets!
    import jregex.*;
    // a float number and string with any blank delimiter
    String patternString ="^([+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][+-]?\\d+)?)\s+(.*)$";
    Pattern pattern = new Pattern(patternString); // different from Sun regex package syntax
    // below is identical in both packages
    Matcher m = pattern.matcher(anyTargetString);
    if (m.matches()) {
      Double d = Double.parseDouble( m.group(1) );
      String scratch = m.group(2);
      // your stuff goes here
    ..Remember to put JRegex jarfile in classpath!
    Regards and Success.

  • TA38622 how do you delete a contact name and phone number from this?  i have deleted it from my regular contacts, but it remains in a text memory when i begin to type the beginning of a name

    How do I delete a contact name and phone number from my texting memory?  I have deleted this contact from my regular contact information; however when I text and begin to text a contact beginning with the 1st letter of the name I had deleted, it brings up the old, deleted contact information in my texting history only.

    You would have to restore as new.

  • Fetch Sales order number and PO number from ship to party and sold to party

    HI,
    I need to get Sales order number and PO number
    from ship to party and sold to party.
    I have only ______sold to party and ship to party and req del date_______ in selection screen as mandatory
    Please let me know
    Sreekanth

    Hi,
    You can do this:-
    SELECT VBELN FROM LIKP
    INTO TABLE T_DELIVERIES
    WHERE KUNNR = SHIP TO PARTY
    AND     KUNAG = SOLD TO PARTY
    AND LFDAT      = DEL DATE.
    You will get a table containing the list of deliveries.
    Use VBFA to get the sales orders from deliveries.
    SELECT VBELV FROM VBFA
    INTO TABLE T_SALESORDERS
    WHERE VBTYP_N = 'J'
    AND     VBELN  = T_DELIVERIES-VBELN.
    T_SALESORDERS WILL give you list of sales orders.
    From Sales Orders you can get Purchase orders through EKKN Table.
    Using EKKN pass T_SALESORDERS-VBELN and get corresponding EBELN.
    Regards,
    SUbhashini

  • Getting host name and port number from application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • Getting host name and port number from an application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • I created in iMovie, and extracted audio from one of the clips to use in the title sequence.  All is well, export to iDVD and it plays OK, but when I burn the DVD the audio for the titles does not play. Any suggestions?

    I created in iMovie, and extracted audio from one of the clips to use in the title sequence.  All is well, export to iDVD and it plays OK, but when I burn the DVD the audio for the titles does not play. Any suggestions?

    I am on a MacBook Pro with OS 10.6.7 running iMovie '11 and iDVD 7.1.1.  Thanks for any input.

  • Need dissociation street name and street number from one column?

    Hi all,
    I have one table A with one column with Street name and street number.
    And I was adding second column and now need update this second column with street number
    and delete street number from first column.
    How can unpluging street name and street number from one column?
    (street name are 90% char, number is 100 numeric, in 10% street name name
    starts with number (1.HEROES 223, 1.HEROES 224...)
    Gordan

    Hi,
    Solution of Mr. Wijk come first, however I like to post (it's very similar and incomplete, I know...). Supose you have a table call address (use position -1 like Mr. Wijk to look backward). It's better in cases like '1.My Street 123' (the space before the number is very important)
    SELECT substr(a.street_name,
                  1,
                  instr(a.street_name,
                        -1) - 1) street_name,
           substr(a.street_name,
                  instr(a.street_name,
                        -1) + 1) street_number
      FROM address a;Regards,

  • How to get Storage unit and Warehouse number from Handling Unit.

    hello all,
    I have Handling unit and Material in my program as an input, using these two fields i have to get corresponding storage unit and ware house number, to pick up transfer order.
    Can anybody explain me who can we get Storage Unit and Warehouse Number from Handling Unit.
    I know we can pull transfer order from table LTAK & LTAP using warehouse number.
    But i dont understand how to get warehouse number from handling unit.
    There is table LSUTO which has warehouse and Handling unit relation, but in our system there is not data maintained in that table. So, i was just wondering how can i get warehouse number from the given handling unit number.
    please guide me
    thanks
    Edited by: Mr A on May 12, 2008 1:23 AM

    Hi ,
        Check out the handling unit item table VEPO. You got storage location(LGORT) in it.
    Reward points if it was useful.
    Regards,
    Abhishek

  • Want to crop an image of car and extract number plate from it.

    i have a problem in my project.I have to crop the edges of a car's image and i want to extract only it's number plate.The OCR i am using can not extract charcters which are skewed etc.Can i have a code through which i can crop an image and extract only specific part?

    Is this a college project ?
    Cos it sounds extremely tricky to attempt.
    If I was attempting this I might
    1. Assume a fixed camera position.
    So that I'd know what the road looked like without any cars.
    Take a photo of this road as a "control background".
    2. Assume a standard number plate system.
    In Ireland, they've a white background, black lettering.
    No italic writing.
    Then, when I detect a car ( say more than 5% of the "control background" is covered ), I might try searching for the black & white lettering.
    This might involve scanning the image from left to right, top to bottom, and defining rectangular ranges of black & white pixels.
    ( I'd allow multiple regions, so there could be more than 1 plate in the photo.
    It might even pick up sign-writing on vans and cars ! )
    That's just my initial quick idea of how to attempt it.
    Could be easier ways...
    regards,
    Owen

  • Validating and Extracting Data from OBSSOCookie

    Hello, I am looking for references on how to validate an OBSSO Cookie that is presented by a user (through their browser) and how to extract values from the cookie (using JAVA API calls in the Access Manager SDK).
    I am not able to locate any references in the developers guide - can someone please assist or point me to some documentation to start?
    Thanks in Advance.

    Here's a snippet from when I did this to get the username from the cookie:
    public String getUser(HttpServletRequest request, HttpServletResponse response) {
    try {
    String sdkLocation = System.getProperty("oam.sdk.location");
    ObConfig.initialize(sdkLocation);
    catch (ObAccessException ie) {
    System.out.println("Initialize failed");
    ie.printStackTrace();
    Cookie cookie = getCookie(request, "ObSSOCookie");
    ObUserSession userSession = null;
    try {
    userSession = new ObUserSession(cookie.getValue());
    catch (Throwable t) {
    t.printStackTrace();
    System.out.println("Failed to create new user session");
    try {
    String DNarray[];
    if (userSession.getStatus() == ObUserSession.LOGGEDIN) {
    String userDN = userSession.getUserIdentity();
    StringTokenizer userST = new StringTokenizer(userDN,",=");
    DNarray = new String[userST.countTokens()];
    for(int i=0;userST.hasMoreTokens();i++){
    DNarray[i] = userST.nextToken();
    userID = DNarray[1];
    System.out.println("user ID is " + userID);
    else {
    System.out.println("Login failed. Return status = " + userSession.getStatus());
    catch (com.oblix.access.ObAccessException obae) {
    obae.printStackTrace();
    obae.getMessage();
    return userID;
    }

  • Extract date from string in T-SQL

    Hi,
    I am having one field(AT_TEXT) in my database that has below kind of values. I want to extract date from this string but the issue is all rows has different format.
    1)One Month Lttr sent on 3/12/2009 due to
    2)One Month Letter sent on 1/15/2009 due to
    3)One Month letter sent on7/15/2011.The amount due             - This has no space between on and 7 and . after yr
    4)One Month letter sent on 7/16/12 due to        - This has 12 instead of 2012(2 positions after 2nd slash/)
    Can anyone please help me to write query to extract date from this string?
    Vicky

    Hi Jingyang
    Li,
    I checked your query and it looks good but I have one issue. So when we reverse it, it looks like below and it is talking that $57.80 as a 1st numeric value and try to convert it into date and giving me error.
    I realize from your query that you are trying to reverse the value and then try to find out 1st Numeric value from that string, but my whole string has another numeric value at the end, like 
    "One Month Letter on 1/15/2009 due to non-pmt of prems-amt to avoid DE is $57.80"
    So when we reverse it, it looks like below and it is taking that $57.80 as a 1st numeric value and try to convert it into date and giving me error.         
    "08.75$ si ED diova ot eud tma - smerp fo tmp-non ot eud 9002/51/1 no retteL htnoM enO"
    Also sometimes I have $ amount at the end and sometimes I don't have any $ amount at the end, like below,
    "One Month letter sent on 10/15/2012 due to non-payment of premiums. The amount due to avoid dise"
    Can you please modify your query which takes only date part not the $ amount and give me?
    Thank you so much for your help 
    Vicky

Maybe you are looking for

  • Raw images are rendering dark green, and Raw FT not working

    Upon loading Raw files from a Canon T5i into Aperture, the previews, when re-rendered by Aperture, turn a dark greenish hue. I've verified that the Digital Camera Raw software is up to date and my Camera is supported. The second issue is that when I

  • Records are not readed

    Hi Experts Sometimes (in reporting or when Im doing calcs by IP functions), not all records are taked in account. Only if I collapse the Infocube, then reporting and calcs are ok.  This happend only with real-time infocubes. Whats happend? How can I

  • Advance Payment Problem

    Hi SAP Gurus, I have a scenario.How to create invoice for advance payment? My scenario is like this: Order is for 100 computers.The computers will be delivered partially.It will be delivered in folowing way: 1st delivery 40qts 2nd delivery 35 qts 3rd

  • Periodic I/O server build error

    Hi folks, Im trying to create a periodic IO server through a Vi I built for a project and have followed the set giudelines in the Getting Started the LabVIEW DSC Module.  I'm getting the following fail when I try to build the IO server. Warning, the

  • Will not accept serial number--why?

    My serial number entered from the one on the plastic case will not be accepted. I currently have Adobe Photoshop Elements 8 and am trying to install APE 10.