Extract 2 characters from string

Hello,
Can anyone help to create a formula to extract 2 characters from the left of "pp" in a field using CR XI?
Field = {MainEstimateDetails.JobDescription} (string)
Sample string details:
"Annual Report 96pp & Cover 12345"  - want to be able to show only 96 (from 96pp)
"CTP A4 4pp" - want to be able to show only 4 (from 4pp)
The string length is variable and the "pp" will be in different places each time.
It is probably very simple, but I cannot get it

Hi, 
You can use the InStr function for this.  InStr returns the position of the string your are looking for. 
NumberVar myPosition;
If InStr ({MainEstimateDetails.JobDescription}, "pp") > 0 Then
    myPosition := InStr ({MainEstimateDetails.JobDescription}, "pp")
Else myPosition := 0;
If myPosition <> 0 Then
    {MainEstimateDetails.JobDescription} [(myPosition - 2) To (myPosition - 1)]
Else "";
This is a bit longer than I would normally do it but... I use Instr to check if the field has "pp" in it.  If it does it will return the character position in the field and I pass that to my variable myPosition. 
If myPosition has a value then it parses out the two characters before "pp". 
Good luck,
Brian

Similar Messages

  • Removing non-numeric characters from string

    Hi there,
    I need to have the ability to remove non-numeric characters from a string and I do not know how to do this.
    Does any one know a way?
    Example:
    Present String: (02)-2345-4607
    Required String: 0223454607
    Thanks in advance

    Dear NickM
    Try this this will work...........
    create or replace function char2num(mstring in varchar2) return integer
    is
    -- Function to remove Special characters and alphebets from phone no. string field
    -- Author - Valid Bharde.(India-Mumbai)
    -- Date :- 20 Sept 2006.
    -- This Function will return numeric representation.
    -- The Folowing program is gifted to NickM with respect to his post on oracle site regarding Removing non-numeric characters from string on the said date
    mstatus number :=0;
    mnum number:=0;
    mrefstring varchar2(50);
    begin
    mnum := length(mstring);
    for x in 1..mnum loop
    if (ASCII(substr(upper(mstring),x,1)) >= 48 and ASCII(substr(upper(mstring),x,1)) <= 57) then
    mrefstring := mrefstring || substr(mstring,x,1);
    end if;
    end loop;
    return mrefstring;
    end;
    copy the above program and use it at function for example
    SQL> select char2num('(022)-453452781') from dual;
    CHAR2NUM('(022)-453452781')
    22453452781
    Chao!!!

  • Strip Characters from String?

    Hi,
    How can I strip off some characters from the end of a string?
    I am not very good at regular expressions but perhaps I may not
    need one? Here is the data
    first_name_510
    last_name_2267
    I need a function that will strip off everything from the
    right including the underscore. I should be left with the below:
    first_name
    last_name
    Any help highly appreciated
    Regards

    if it is always an underscore, and always the last one, this
    should do
    the trick:
    #left(string, len(string)-len(listlast(string, "_"))-1)#
    string is assumed to be the variable holding your text
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

  • Extract Characters from String

    Hi
    Can anyone let me know how can i extract the letters HIJK from the following string
    Sting s = "ABCDEFGHIJKLMNOP"
    Thanks

    Thanks for that
    but if i do something like this it falls over
    String temp = s.substring(12, 3);You posted this response 2 minutes after the previous response. This means you obviously didn't take the time to read the String API to find out more information about the parameters for the method. Take some time to learn about new methods before claiming they don't work.

  • How to extract the Datetime from string?

    Hello FOlks,
    I have the sample data whichi is a string and it contains DateTime part inside it. I worked through half way but am not sure how to get the other part.
    The sample data is
    Note Added by AARON HILTON at 05/26/2010 14:53 MONEY NOTE ENTERED
    Note Added by DEBBIE BILL at 11/16/2009 23:12 MONEY ENTERED
    I tried using
    substr(d.assignee_note, INSTR(d.assignee_note,'at')+2,length(d.assignee_note))  but it did not have the desired results.
    How to just extract the datetime part i.e. 11/16/2009 23:12

    If your sample data is representative for all the data, you could also try a regular expression:
    SQL> -- generating sample data, pretending it's stored in a column called str in a table called t:
    SQL> with t as (
      2  select 'Note Added by AARON HILTON at 05/26/2010 14:53 MONEY NOTE ENTERED' str from dual union
      3  select 'Note Added by DEBBIE BILL at 11/16/2009 23:12 MONEY ENTERED' from dual
      4  )
      5  --
      6  -- actual query:
      7  --
      8  select trim(regexp_replace(str, '[[:alpha:]]')) str
      9  ,      to_date(trim(regexp_replace(str, '[[:alpha:]]')), 'mm-dd-yyyy hh24:mi') dt
    10  ,      to_timestamp(trim(regexp_replace(str, '[[:alpha:]]')), 'mm-dd-yyyy hh24:mi') ts
    11  from   t;
    STR                DT                        TS
    05/26/2010 14:53   26-05-2010 14:53:00       26-05-10 14:53:00.000000000
    11/16/2009 23:12   16-11-2009 23:12:00       16-11-09 23:12:00.000000000
    2 rows selected.where column STR is, well, a string, DT will turn your string into date datatype and TS will turn it into a timestamp.
    It isn't clear how you want to extract the datetime part, but it really matters...

  • Extraction of Numbers from string in oracle

    Dear All,
    I have a AplhaNumeric field in my source table which holds the string with numbers and caharcters .i need to extract only numbers and to load into the target table which of number type.
    can any one suggest me about how to do this?
    regards
    kumar

    Hi ,
    I have a table called smitems with column smitmqtyremarks which holds alpha numeric characters .nearly 180 records exists in this table.
    i need extract numbers for this field and load into my target tables.
    here i am giving sample rows for this field :
    smitmqtyremarks
    13 قطعة
    4 لحاف
    31 قطعة
    120 قطعة
    57 قطعة
    110 قطعة
    127قطعة
    169 قطعة
    12 مفرش
    10 مفارش
    110 قطعة
    170 قطعة
    20 خرطوشة
    28 قطعة
    60قطعة
    70 قطعة
    80 لعبة
    70 قطعة
    20 قطعة
    60 قطعة
    50 قطعة
    10 رولات
    4 رولات
    35 دسته
    50دستة
    7 رول
    3 اثواب قماش
    خمسة خرطوشة سجائر
    50 جاكت حريمى ورجالى
    10 رول اقمشة 4 دسته
    420 جوارب اطفال
    60 خرطوشة سجائر
    12 رول
    15 خرطوشة
    110 علبة
    45 قطعة
    40 قطعة
    44 قطعة
    22 قطعة
    3 خرطوشة
    468 قطعة
    38 قطعة
    80 رول قماش
    2 رول
    6 رول اقمشة
    13 رول اجنبى الصنع
    100 دسته صينى الصنع
    18 رولات ملابس
    10دسته
    90قطعة
    33 قطعة
    39 قطعة
    42 قطعة
    300 ايشارب
    500 قطعة
    19000 ك 0ج
    607 قطعة
    24 قطعة
    45 قطعة
    40 اروسه
    5 رول اقمشة اجنبية الصنع
    75 قطعة
    5 قطعة
    4 رول
    26 قطعة
    50قطعة
    105 قطعة
    650 جرام
    65 قطعة
    50 خرطوشة
    4 خرطوشة
    80 قطعة
    100 بنطلون
    500 قطعة
    40 قطعة
    42قطعة
    1 خرطوشة
    14 قطعة
    80 قطعة
    7 خرطوشة سجائر
    230 لمبة
    50 قطعة
    50قطعة تليفون
    14 كرتونة
    4 كرتونة احذية
    17 كرتونة خزف
    22 لحاف
    16كرتونة ادوات صحية
    8كرتونة
    28 كرتونة
    2كرتونة
    15كرتونة
    115 قطعة
    6448
    1937قطعة
    1937 قطعة
    2628كجم
    6.980طن
    9 كرتونة
    18 شفاط
    صواميل حديد
    3كرتونة +20 قطعة
    39.480طن ق.غ سيارات
    25كرتونة مصنوعات خزفية
    50بنطلون
    8 كرتونة كلبسات
    20كرتونة اكسسوار حريمى
    279كرتونة لحوم
    38 اطار كاوتش
    10كرتونة
    4كرتونة
    10كيلو
    عدد5 ماكينات
    41سيارة
    سيارة
    90 قطعة ملابس
    22250كجم
    1793كجم
    1371كرتونة زجاج
    مستندى
    252شاشة
    5كرتونة
    320قطعة
    45خرطوشة
    98 قطعة
    10لفات
    25كجم
    320كجم
    5كراتين
    47طرد
    50قطعة
    117كجم
    1200 قطعة ملابس
    5كجم
    75جهاز
    40قطعة
    5كراتين
    10كجم
    250ق
    200ق
    200 توب
    20لفة
    30لفة
    2دستة
    95قطعة
    70قطعة
    57523طن طلمبات مياه
    43732كجم
    755كرتونة
    10.645طن
    1537طرد
    11751كجم
    مكبس
    77426.80متر
    2600قطعة
    339طن
    15120كجم
    مختلفة
    267طرد
    1200كجم
    189عبوة
    499كرتونة
    10000كجم
    960طرد
    15.770كجم
    111قطعة
    174طرد
    22000كجم
    473000علبة
    6720كجم
    145خرطوشة
    2500طن
    3660كجم
    27824كجم
    8682كجم
    14000كجم
    6400كجم
    133كرتونة
    2738كجم
    the characters are in arabic here.
    hope it clears my issue.
    please suggest me the right query for this to get only numbers
    thanks
    kumar

  • Extract balanced parantheses from String

    Hi community,
    I am getting back to work on LabVIEW after long.
    Currently implementing an algorithm and I need to work with tree like structures presented in the form of strings with parantheses.
    So, for example, a string such as A(B(c,d),P(q,r),U(V(w),X(y,z,o))) has a tree with root node A, and there are three children of A, namely B, P, U, and all of them also represent a tree (sub-tree of the original tree A). So that, B is the root of the sub-tree where c and d are the two nodes. U also has two children that represent individual sub-trees, namely V (with one child) and X (with three children).
    Although, there is one detail, which may actually help the process a bit. The trees are simplified, so that all the nodes that represent some tree (or sub-tree) are just called S.
    To extract all these trees, I am going to check one element at a time and then build the sub-trees one by one.
    Just thought to ask here if someone has a better idea (or if some function from OpenG may help here if someone has done something similar). Always ready to learn!
    Thanks ahead!
    Vaibhav

    Ok, I just finished the function to validate the input string, extract all the valid sub-trees and list them.
    The VI and the required Sub-VI are in the attachment.
    This is just to show what output do I need. Any suggestions to improvements are most welcome.
    And if someone finds this solution as useful, I would appreciate acknowledgement of that too (Kudos ).
    But my main objective is to know how this could be done in a smarter way.
    Try to play with the function with different valid and invalid tree automata strings. Be careful with the root symbol.
    In the above post I used "S" as the root symbol, and in the VI, I am using "X" by default. So just change either of them.
    Try for example,
    X(a,b)     - valid  - 1 tree
    X(X(a,b))     - valid - 2 sub-trees
    X((a,b))     - invalid
    X(a,b))     - invalid
    X(X(a,b)     - invalid
    X(X(a),  X(X(b)),X(c,X(d )) )     - valid (it will remove the unnecessary spaces that the user might add mistakenly) - 6 sub-trees.
    Could I get these results through regular expressions?
    Remark: I didn't put small checks like if the user gives a multi-char string as the Root symbol or things like that, just to implement quickly. I assume the user will not make deliberate mistakes like this.
    In the front panel of the main VI (Validate and Extract Sub-trees.VI), you may ignore the array A2, as it was mainly for my debugging purposes. The array A2 is filled while the program runs, and you may see my logic in those cells. But ignore otherwise.
    Cheers!
    [Edited 03/24/2014: Attachment with private information removed at poster's request]
    Vaibhav

  • Extracting numeric data from string

    Dear all,
    how can i extract a numeric part of a Varchar2 column..
    the data is
    transaction 111.98 sucess
    gsdhgadg 52365.878 hdfjhfd
    ttqweqwg3321.7676jdshfjhsf
    from all the above strings i want to extract 111.98 ,52365.878 ,3321.7676
    how can i do it in teh most efficient way.. is theer any analytical function inplace for doing this?
    please help..

    edogt wrote:
    hi,
    this is my solution:
    declare
    anumber varchar2(100) ;
    text varchar2(100) := 'transaction. 111.98 sucess' ;
    begin
    anumber := regexp_substr(text,'[[:digit:]]+(\.[[:digit:]]+)*');
    dbms_output.put_line(anumber);
    end ;Which doesn't work if you test it against the OP's latest requirement...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'transaction 111.98 sucess' as txt from dual
      2       union select 'gsdhgadg 52365.878 hdfjhfd' from dual
      3       union select 'ttqweqwg3321.7676jdshfjhsf' from dual
      4       union select 'IT2 Power Resis;UPI 2.4900;QTY10' from dual)
      5  -- end of test data
      6  select txt, regexp_substr(txt, '[0-9]+\.[0-9]+') as num
      7            , regexp_substr(txt,'[[:digit:]]+(\.[[:digit:]]+)*') as num2
      8* from t
    SQL> /
    TXT                              NUM                              NUM2
    IT2 Power Resis;UPI 2.4900;QTY10 2.4900                           2
    gsdhgadg 52365.878 hdfjhfd       52365.878                        52365.878
    transaction 111.98 sucess        111.98                           111.98
    ttqweqwg3321.7676jdshfjhsf       3321.7676                        3321.7676
    SQL>P.S. you should wrap your code with {noformat}{noformat} tags so that it's displayed properly.  ;)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Removing unicode control characters from string

    Hi.
    I have a webservice where I return an object (with some strings) back to the client. The information is read from a database, and the string can sometimes contain invalid xml characters (like unicode 0x13). This results in an error when parsing the information at the client side.
    Is there someway a easy way to set up a filter or something that checks whether the string contains characters outside the valid range specified for XML's (lower than unicode 0x20 etc), and removes them/replace them with a different character?

    If you have to get rid of the control chars then       String someText = "a\nb\nc\td\re\r\nf";
            String someTextWithoutControlChars = someText.replaceAll( "[\u0000-\u0020]","");
            System.out.println(someTextWithoutControlChars);but like kaj says, some control chars are valid.

  • Extract min timestamp from string

    Hello all,
    I am trying to query the minimum datetime from a column that is stored as nvarchar(max). There a a few tricky things with this query (at least for me)
    - There is more than just the date being stored within each record. 
    -The position of the datetime is relative- although it does always appear in the format '**(DD-MM-YY at HH:MM PM' 
    -There are multiple datetimes stored in each record-so not only do I need to locate and capture where there is a datetime, I need to find the minimum datetime within the record
    - I can't just change the format that the data is stored in- there is over a decade of information that is stored this way.
    Please Help
    The column is called 'hdresp'
    Here is sample data:
    **(03-Apr-14 at 09:44 AM email sent) -- Billy Bob:  Upgrade ordered.    **(02-Apr-14 at 04:16 PM email sent) -- Sammy Richards:  I can give you another cable to if you think that will help but it just might be time for an upgrade.  If
    you want to go that route I have to ask that you submit another request for New Hardware.    **(02-Apr-14 at 03:17 PM email sent) -- Paul Smith:  Michael  Stop by my desk when you have a second.
    -What i would like to end up with is a query that identifies '02-Apr-14 at 3:17 PM' as the minimum time and converts it to 'YYYY-MM-DD HH:MM:SS' -for example '2014-04-02 15:17:00' 
    Thanks!

    Thank you everyone for your help!
    I ended up using this to extract and convert the minimum time from a string:
    SELECT CONVERT(datetime, REPLACE(LEFT(RIGHT(hdresp, PATINDEX('%(**%', REVERSE(hdresp)) - 1), 21), 'at ', ''))
    from tblhdmain
    where hdindex = 211458
    Which gave me the result:
    2014-04-02 15:17:00.000

  • How to extract special characters from a field

    Hi there.
    I am a novice when it comes to Web Intelligence reports. I have been tasked with producing a final report that I can export to Excel which shows a project number and a project name. Very simple. Ultimately I need to import my final Excel file to a third party software. However, the issue is the project name field consists of special characters such as hyphens, parenthesis, asterisks, etc. I need to be able to create a formula which extracts all special characters and just leaves me with alpha-numeric characters and spaces. I also need to limit the character count to no more than 34 characters. I will not be able to import my final Excel file unless I can product those results. With the help of a very knowledgable person in the Crystal Reports forum, I was able to do that by using the following formula:
    stringvar a:=left({Projects.ProjectName},34);
    numbervar i;
    Local StringVar fin;
    for i:= 1 to len(a) do
        if a[i]in ["a" to "z"] then
            fin := fin & a[i]
        else if a[i] in ["1" to "9"] then
            fin := fin & a[i]
    else if a[i] = " " then
         fin := fin & a[i];
    fin;
    It worked amazingly well in Crystal Reports but this report now needs to move to Web Intelligence. Is there a way to do this in a Web Intelligence report? Itried but the formula is not recogizable. I tried creating a variable and using this formual but I couldn't get it to work.  I appreciate all helpful responses. The version of Web Intelligence I am using is SAP Business Enterprise XI. I am working in a PC environment using Windows 7 if that helps at all.
    Thank you!
    Lauren

    Hi Lauren, Please provide with some sample data...
    In SQL, by writing some Functions/Procedures you can eliminate special characters. Ask your database team to do that.
    or
    Create an object with the following syntax... It Works in SQL.
    = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE
    (REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE
    (REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE
    (REPLACE(REPLACE(REPLACE([String_Object],'&',' '),'*',' '),'(',' '),'^',' '),'%',' '),'!',' '),'@',' '),'#',' '),'$',' '),'~',' '),')',' '),'+',' '),'=',' ' ),'-',' '),'_',' '),'/',' '),':',' '),';',' '),',',' '),'<',' '),'.',' '),'>',' '),'?',' '),'"',' '),'''',' '),'[',' '),']',' '),'{',' '),'}',' '),'\',' '),'|',' ')
    Example: Input: '~!@#$%^&*()_+{}:"<>-=[]./\|/*-+ascdfv123'
                  Output: ascdfv123

  • Removing characters from string after a certain point

    Im very new to java programming, so if this is a realy stupid question, please forgive me
    I want to remove all the characters in my string that are after a certain character, such as a backslash. eg: if i have string called "myString" and it contains this:
    109072\We Are The Champions\GEMINI
    205305\We Are The Champions\Queen
    4416\We Are The Champions\A Knight's Tale
    a00022723\We Are The Champions\GREEN DAYi would like to remove all the characters after the first slash (109072*\*We...) leaving the string as "109072"
    the main problem is that the number of characters before and after is not the always the same, and there is often letters in the string i want, so it cant be separated by removing all letters and leaving the numbers
    Is there any way that this can be done?
    Thanks in advance for all help.

    You must learn to use the Javadoc for the standard classes. You can download it or reference it on line. For example [http://java.sun.com/javase/6/docs/api/java/lang/String.html|http://java.sun.com/javase/6/docs/api/java/lang/String.html].

  • Remove of non-printable characters from string

    Hi Gurus,
    How can I achive that? I have a string in which sign "end of line" occurss. How can I delete them?
    BR
    Marcin Cholewczuk

    Hi Marcin,
    Just use a [REPLACE|http://help.sap.com/abapdocu_70/en/ABAPREPLACE.htm] with a regular expression (Assuming variable STRING holds your data):
    replace all occurrences of regex '[\n\r]+' in STRING with ''.
    Note that I replaced newline ('\n') - also called end of line - and carriage return ('\r') with nothing (matching your delete request). This might not be wanted if you have a true multiline string. If you're more paranoid and want to cover more cases, you might want to replace any non-displayable characters using '\[\[:print:\]\]+' as your search pattern. So if you want to replace non-displayable characters with a space and just kill it at the end of the string you could use something like this:
    replace all occurrences of regex '[^[:print:]]+(?!$)' in STRING with ` `.
    replace all occurrences of regex '[^[:print:]]+$' in STRING with ''.
    Cheers, harald

  • Retreiving number and characters from string

    Hello fellow developers,
    Lets say i have the following string ER686 and want to split the string into a number and characterpart resulting in a String "ER" and an int "686". What is the best approach to accomplish this?
    Thank you for any help offered.

    The format is that there's a sequence of strings 2 or
    3 and a squence of numbers 3 or 4You might use a Pattern matcher, using a regular expression like the following :"(\\D{2,3})(\\d{3,4})"This expressions represents "two or three non-digit characters followed by 3 or 4 digits". The parenthesis are here to allow getting the two elements (groups) separately.
    Use the find() method of the matcher, then retrieve the two groups with group(1) and group(2).
    Eventually, parse the latter if required.

  • Capturing characters from string

    Hey guys, I need a little bit of help. Thanks in advance!
    I have a user text input and I'm trying to save only the numbers in that string into a variable.
    For example: User enters "J123JS"
    var userNum=123
    How can I do so?
    Also, I'd like to check if a certain character is not a number or specified character then reneder an Error message to Output text.
    So far I have:
    var ch1=textbox.charAt(0);
    var ch2=textbox.charAt(1);
    var ch3=textbox.charAt(2);
    var ch4=textbox.charAt(3);
    if (ch1== /[^NWSE]/){ txtOutput.text="Error!!"; < This does nothing in my program. Renders no erros, yet does nothing!\
    I also tried:
    if (ch1== /[ABCDFGHIJKLMOPQRTUVWXYZ]/){ txtOutput.text="Error!!"; }
    still, nothing!
    Also, I'm trying to say if the 3rd character is not a number then render an error message
    I've tried:
    if (ch3!=/[0-9]/){
    txtOutput.text="Error!";
    No luck.
    Please help, thanks.

    To just extract numbers:
    var userNum:Number = Number(textbox.text.match(/\d/g).join(""));
    To check if there are number at all:
    if(!/\d/g.test(textbox.text)){
         txtOutput.text="Error!";
    To check by position:
    if (!Number(textbox.text.match(/./g)[3])) {
         txtOutput.text="Error!";

Maybe you are looking for

  • Dead Screen-Photo recovery

    My screen is dead-I had to buy a new phone. I want to recover my photos (and other things, if I can) but when I plug my phone in to iTunes it asks me to unlock my screen, which I can't do. I haven't updated to my computer or iCloud lately. Is there a

  • New camera for old iPhoto

    We've been intending to buy a new camera for a bit, nothing fancy, just something a bit better than our now antique Canon (PowerShot A10) (yes, really!) and that can shoot some brief video. Just as I was about to buy, I wondered whether all the new c

  • BEx Analyzer 7.0 result column

    Hi Gurus I have a question regarding the BEx Analyzer 7.0. Hope you can help. My customer wants to use BEx Analyzer 7.0 but is not happy with the fact that the excel query result starts in column F instead of column A (like the old BEx Analyzer did.)

  • HP Pavilion DV6 Notebook / Simple Pass Inactive

    I have a HP Pavilion DV6 notebook.  The Simple Pass program has been set up and was working for a year and all of a sudden I stopped getting the prompt to scan my finger as I accessed registered websites needing logins.  My fingerprint reader still w

  • [svn:osmf:] 13993: Moving ControlBarPluginSample and Test into the plug-ins folder.

    Revision: 13993 Revision: 13993 Author:   [email protected] Date:     2010-02-05 00:45:05 -0800 (Fri, 05 Feb 2010) Log Message: Moving ControlBarPluginSample and Test into the plug-ins folder. Added Paths:     osmf/trunk/apps/samples/plugins/ControlB