Regular expression to check the sequence of strings

HI,
I am validating an EDI document like as follows
ISA*XX*XXXXXXXXXXXXXXX*XX*XXXXXXXXXXXXXXX*030130*0912*~IEA*1*000005900~
I need to create a regular expression which checks ISA should always occur before IEA.
Please help me if you have any hints.
Thanks.

Thanks.I had taken that into consideration.
But using regular expression I could say
ISA* only once
IEA* only once
And
ISA before IEA
Any hints how to specify "before"/sequence using Regular expression ?
I agree sometime using basic String operation we can do this.

Similar Messages

  • Regular expression help please. (extractin​g a string subset between two markers)

    I haven't used regular expressions before, and I'm having trouble finding a regular expression to extract a string subset between two markers.
    The string;
    Header stuff I don't want
    Header stuff I don't want
    Header stuff I don't want
    Header stuff I don't want
    Header stuff I don't want
    Header stuff I don't want
    ERRORS 6
    Info I want line 1
    Info I want line 2
    Info I want line 3
    Info I want line 4
    Info I want line 5
    Info I want line 6
    END_ERRORS
    From the string above (this is read from a text file) I'm trying to extract the string subset between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number 1 through 32, and the number of lines I want to extract will correspond with this number. I can supply this number from a calling VI if necessary.
    My current solution, which works but is not very elegant;
    (1) uses Match Regular Expression to the return the string after matching ERRORS 6
    (2) uses Match Regular Expression returning all characters before match END_ERRORS of the string returned by (1)
    Is there a way this can be accomplished using 1 Match Regular Expression? If so could anyone suggest how, together with an explanation of how the regular expression given works.
    Many thanks
    Alan
    Solved!
    Go to Solution.

    I used a character class to catch any word or whitespace characters.  Putting this inside parentheses makes a submatch that you can get by expanding the Match Regular Expression node.  The \d finds digits and the two *s repeat the previous term.  So, \d* will find the '6', as well as '123456'.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • Firefox is not remembering passwords for sites that i visit regularly. Ihave checked the box "remember passwords for sites" in the security tab under tools, but the passwords are not being remembered when I return to the sites.

    Firefox is not remembering passwords for sites that i visit regularly. Ihave checked the box "remember passwords for sites" in the security tab under tools, but the passwords are not being remembered when I return to the sites. I am running v 3.6.18

    Websites remembering you and automatically log you in is stored in a cookie.
    * Create an allow cookie exception (Tools > Options > Privacy > Cookies: Exceptions) to keep such a cookie, especially for secure websites and if cookies expire when Firefox is closed.
    Make sure that you do not run Firefox in Private Browsing mode.
    * https://support.mozilla.com/kb/Private+Browsing
    * In [[Private Browsing]] mode all cookies are session cookies that expire if that session is ended, so websites won't remember you.
    * Do not use [[Clear Recent History]] to clear the "Cookies" and the "Site Preferences"
    Clearing "Site Preferences" clears all exceptions for cookies, images, pop-up windows, software installation, and passwords.
    * http://kb.mozillazine.org/Cookies

  • Unique regular expression to check if a string contains letters and numbers

    Hi all,
    How can I verify if a string contains numbers AND letters using a regular expression only?
    I can do that with using 3 different expressions ([0-9],[a-z],[A-Z]) but is there a unique regular expression to do that?
    Thanks all

    Darin.K wrote:
    Missed the requirements:
    single regex:
    ^([[:alpha:]]+[[:digit:]]+|[[:digit:]]+[[:alpha:]])[[:alnum:]]*$
    You either have 1 or more digits followed by 1 or more letters or 1 or more letters followed by 1 or more digits. Once that is out of the way, the rest of the string must be all alphanumerics.  The ^ and $ make sure the whole string is included in the match.
    (I have not tested this at all, just typed it up hopefully I got all the brackets in the right place).
    I think you just made my point.  TWICE.  While the lex class would be much more readable as a ring.... I know all my brackets are in the correct places and don't need to hope.
    Jeff

  • How to form a regular expression for matching the xml tag?

    hi i wanted to find the and match the xml tag for that i required to write the regex.
    for exmple i have a string[] str={"<data>abc</data>"};
    i want this string has to be splitted like this <data>, abc and </data>. so that i can read the splitted string value.
    the above is for a small excercise but the tagname and value can be of combination of chars/digits/spl symbols like wise.
    so please help me to write the regular expression for the above requirement

    your suggestion is most appreciable if u can give the startup like how to do this. which parser is to be used and stuff like that

  • Regular Expression to capture user's input string

    I am writing a helper class to split user input string into String array according to the following pattern:
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    public class TestDelimiter {
    static Pattern p = Pattern.compile("(.*?)[,;]{1}");
    static Matcher m;
        public static void main(String[] args) {
            String input = "AAA111111,BBB222222;CCC333333";
            m = p.matcher(input);
            while(m.find()){
                String output = m.group(1);
                System.out.println(output);
    }Output:
    AAA111111
    BBB222222My question is, how can I modify the regular expression string so that the CCC333333 (last element) can also be included?

    roamer wrote:
    Ok, let's don't argue on this point.Who's arguing?
    I think I got the answer. For simplicity, I can just manually add a ";" or "," string after each user input. Just like:You never said anything about that before. You asked how to split "AAA111,BBB222;CCC333" into its components and you were given a correct answer.
    Maybe you should rephrase your question including this added requirement. Do you need to have the separator included in the final outputs or why do you want to suddenly add things to user input?

  • Regular expression to check a value if it contains a specific word.

    Hi All,
    How can i check if a certain word exists in a value in regular expression ?
    I have an attribute called Race. Race can contain the following:
    White, Non-Hispanic
    Black, Non-Hispanic
    White, Non Hispanic
    Black, Non Hispanic
    White, NonHispanic
    Non-Hispanic, white
    Non Hispanic - black
    What i want is to check if my value contains the word "NON" (NON can be at the beginning, middle or end), if it does, parse it and return it.
    This is what I have, however I want to make sure it covers all cases and not missing anything else
    select REGEXP_SUBSTR(UPPER(trim('Black, Non-Hispanic')), '[NON]+') from dual;Thanks in advance.

    Rooney wrote:
    Could you please explain what are the 2 ones's for ?The two 1 are not really needed for this. It is just taht the syntax requires those parameters when I add the fifth parameter.
    http://docs.oracle.com/cd/E14072_01/server.112/e10592/functions148.htm
    First 1 is where the search starts (same as in substr('Abc',1))
    Second 1 is the number of occurences. Here meaning return the first occurence that was found. Replace it with 2 in my next example to see a (very slight) difference.
    Also 'NON' alone will not cover all cases ?But you don't have non alone. You have regexp with non + upper. The 'i' replaces the upper. Also the output is slightly different. the 'i' version will return the same capitalization as it was found in the original. It depends a little what you want to achieve. And of cause INSTR will give the same info as your version. if the result is > 0 it means NON was found.
    with testdata as (select 'White,Non-Hispanic' str from dual union all
                      select 'Non-White,nOn-Hispanic' str from dual union all
                      select 'White,Hispanic' str from dual
    /* end of test data creation */
    select str,
          REGEXP_SUBSTR(UPPER(TRIM(str)), 'NON') regexp1,
          REGEXP_SUBSTR(str, 'NON',1,1,'i') regexp2,
          instr(upper(str),'NON') instr
    from testdata;
    STR                    REGEXP1                REGEXP2                INSTR
    White,Non-Hispanic     NON                    Non                        7
    Non-White,Non-Hispanic NON                    Non                        1
    White,Hispanic                                                           0

  • Regular expression breaks with \00 in input string

    I wrote the following code to illustrate the problem.
    Clearly the match should occur in both cases, but it does not occur if \00 is in the input string (within the < > ).
    I am not even searching for \00 or \01. This makes the regular expression match rather useless if you have text that contains data in hex form. I am using Labview 8.2. Is this a known bug? Is there a work around?
    Tammo
    Message Edited by Tammo on 03-06-2008 12:26 PM
    Message Edited by Tammo on 03-06-2008 12:26 PM
    Attachments:
    RegEx1.vi ‏56 KB
    BlockDiagram1.jpg ‏18 KB
    FrontPanel1.jpg ‏18 KB

    There was a brief discussion on this not too long ago.

  • Regular expression not giving the required output.

    Hi , I have msgs that look like this :
    dear john smith you Bought 500 shares of Nile Cotton Ginning at 14.9 L.E On 21/01/10
    Im using the Regular expression to get 4 substrings of this msg
    1-Bought|Sold
    2-Quantity of shares (ex: 500)
    3-Name of the stock (ex:Nile Cotton Ginning)
    4-price (ex:14.9)
    Here is my code , but the output returns the whole msg back :
    select SMSID,SMSNO,CUSTOMERACCOUNTID,SENDDATE,ENTRYDATE,
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at (.*)','\1')),'(watheeqa)') buy_sell
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at (.*)','\2')),'(watheeqa)') amount ,
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at (.*)','\3')),'(watheeqa)') company ,
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at ([0-9]*\.[0-9]*|[0-9][^A-Z][^a-z]) .*','\4')),'(watheeqa)') price
    from SMSOUTMSG@bimsic s
    where trunc(SENDDATE) = trunc(sysdate) -1
    and exists (select 1 from PHONEDETAIL@bimsic p
                where s.CUSTOMERACCOUNTID = p.CUSTOMERACCOUNTID
                and SMSFLAG = 1);Thanks.

    It does check it out
    with t
    as
    select 'dear john smith you Bought 500 shares of Nile Cotton Ginning at 14.9 L.E On 21/01/10' smstext from dual
    select
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at (.*)','\1')),'(watheeqa)') buy_sell,
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at (.*)','\2')),'(watheeqa)') amount ,
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at (.*)','\3')),'(watheeqa)') company ,
    regexp_replace(trim(regexp_replace(SMSTEXT,'^.* you (Sold|Bought)(.*) of (.*) at ([0-9]*\.[0-9]*|[0-9][^A-Z][^a-z]) .*','\4')),'(watheeqa)') price
    from t

  • Regular Expression to Check number with at least one decimal point

    Hi,
    I would like to use the REGEX_LIKE to check a number with up to two digits and at least one decimal point:
    Ex.
    10.1
    1.1
    1
    12
    This is what I have so far. Any help would be appreciated. Thanks.
    if regexp_like(v_expr, '^(\d{0,2})+(\.[0-9]{1})?$') t

    Hi,
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    SammyStyles wrote:
    Hi,
    I would like to use the REGEX_LIKE to check a number with up to two digits and at least one decimal point:
    Ex.
    10.1
    1.1
    1
    12
    This is what I have so far. Any help would be appreciated. Thanks.
    if regexp_like(v_expr, '^(\d{0,2})+(\.[0-9]{1})?$') t
    Do you really mean "up to two digits", that is, 3 or more digits is unacceptable?  What if there are 0 digits?  (0 is less than 2.)
    Do you really mean "at least one decimal point", that is, 2, 3, 4 or more decimal points are okay?  Include some examples when you post the sample data and results.
    It might be more efficient without regular expressions.  For example
    WHERE   TRANSLATE ( str              -- nothing except digits and dots
                      , 'A.0123456789'
                      , 'A'
                      )   IS NULL
    AND     str           LIKE '%.%'     -- at least 1 dot
    AND     LENGTH ( REPLACE ( str       -- up to 2 digits
                    )     <= 2

  • Check the sequence of events

    Hi all.
    I have to check the order of a series of events than represents the route of some product. Depending if i'm receiving or delivering the product can occur differents events, the problem is that not all the events are sequential.
    For example:
    I f i am delivering a product, can occur any of this events
    1.- Loaded
    2.- Stopped for repair
    3.- Released for repair
    4.- Stopped for rain
    5.- Released for rain
    6.- Delivery
    The 2 and 3 events are sequential such as 4 and 5, but 2 is not always before 4. Another variant is that the events 2 and 3 could happen but not 4 and 5 or vice versa.
    To complete my task I have only the following tables:
    -- If a delivery or receiving cargo
    CATALOG _ROUTE (
    ID_R      NUMBER
    TYPE      VARCHAR2
    -- All possible events
    CATALOG_EVENTS(
    ID _E             NUMBER
    TYPE      VARCHAR2
    -- Combination of events and routes
    ROUTE_EVENTS(
    ID_RE           NUMBER
    ID _R                  NUMBER
    ID_E          NUMBER
    Precedence     NUMBER
    The precedence field is used only for certain cases, such events 2 and 3 or 4 and 5.
    -- Events
    Events(
    ID_EV NUMBER
    EVENT_DATE DATE)
    The aim is to ensure that all events have been captured correctly

    Hi,
    Welcome to the forum!
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data. You don't have to post a lot of data. In this case, it looks like maybe six routes (some of which are valid, and some of which have various illegal combinations of events) would be enough.
    This looks like a job for analytic funtions. LEAD and LAG are great for comparing values from consecutive rows of the the same data set. Other analytic functions, such as COUNT, FIRST_VALUE and MIN, sometimes combined with a CASE expression, can find values from farther away.
    Sorry, I don't fully understand your business rules, so I can't be more specific now. Maybe I could show you exactly if I had a concrete example, including CREATE TABLE and INSERT statements for all the relevant tables, and the results you wanted from that data.

  • Regular expression to abbreviate the names

    Friends,
    I have tables names like MY_TABLE_NAME, and I need to generate the abbreviations for the tables as MTN. Can any one help me to get using regular expression?
    Thanks,
    Natarajan

    SQL> select table_name, regexp_replace(initcap(table_name), '[[:lower:]]|_') new_tab_name from user_tables
    TABLE_NAME                     NEW_TAB_NAME                 
    UT_METADATA                    UM                           
    V_DELIVERY_DC_DW               VDDD                         
    V_DBWE_DW                      VDD                          
    PLAN_ZIP                       PZ                           
    JOB_HISTORY                    JH                           
    DEMO_USERS                     DU                           
    DEMO_CUSTOMERS                 DC                           
    DEMO_ORDERS                    DO                           
    DEMO_PRODUCT_INFO              DPI                          
    DEMO_ORDER_ITEMS               DOI                          
    DEMO_STATES                    DS                           
    DEMO_PAGE_HIERARCHY            DPH                          
    PLAN_TABLE                     PT                           
    UT_LOOKUP_CATEGORIES           ULC                          
    MV_CORES                       MC                           
    PRODUCTS_QUALITY               PQ                           
    V_BSTPOS_DW                    VBD                          
    TRN_BR                         TB                           
    GL_BR                          GB                           
    V_FAKTUR_DW                    VFD                          
    CHANGE_LOGS                    CL                           
    V_FAKTUR_OLD_DW                VFOD                         
    T_EXT                          TE                           
    TRANSFER_GLOBAL                TG                           
    ORDER_LINES                    OL                           
    T_ERR                          TE                           
    UT_SUITE_TEST_RESULTS          USTR                         
    UT_SUITE_RESULTS               USR                          
    UT_TEST_RESULTS                UTR                          
    UT_TEST_COVERAGE_STATS         UTCS                         
    UT_TEST_IMPL_RESULTS           UTIR                         
    UT_TEST_IMPL_ARG_RESULTS       UTIAR                        
    UT_TEST_IMPL_VAL_RESULTS       UTIVR                        
    UT_SUITE_TEST                  UST                          
    UT_SUITE                       US                           
    UT_LIB_DYN_QUERIES             ULDQ                         
    UT_LIB_VALIDATIONS             ULV                          
    UT_LIB_TEARDOWNS               ULT                          
    UT_LIB_STARTUPS                ULS                          
    UT_TEST_IMPL_ARGUMENTS         UTIA                         
    UT_VALIDATIONS                 UV                           
    UT_TEST_IMPL                   UTI                          
    UT_TEST_ARGUMENTS              UTA                          
    UT_TEST                        UT                           
    UT_LOOKUP_VALUES               ULV                          
    UT_LOOKUP_DATATYPES            ULD                          
    ERR_DT                         ED                           
    47 rows selected.

  • Regular Expression - Select two words after specific string

    Hi,
    I am trying to select the two words/strings after the first word "door". I am using the search pattern (?<=door).\w+ but in this case I get the complete text after the word "door". I only want to select the two words after the first "door" in the complete text.
    Can anybody help me?
    Thanks!
    Marco Snels

    Hi Marco,
    I'm relatively handy with RegEx but this seems like a problem where I would employ a little bit of RegEx and CTL, just to make life easier.
    You can use the following RegEx (note: I didn't test this in Integrator, only in a RegEx testing tool) to extract the two words after door (but including door, unfortunately):
    (?:door)[\s]\w+[\s]\w+
    This would give you something like the following in your extracted field:
    door is brown
    You could then pass through a re-formatter to remove "door" and the whitespace and be on your way. Not the best answer but should perform reasonably well and get you up and going.
    Regards,
    Patrick Rafferty
    http://branchbird.com

  • Regular Expression to check for some of the special characters

    Can someone please provide me a RegularExpression to check if a string contains any of the speical characters i.e. *!@#$%^&*()_+ []{}:;',./<>?~`*
    Thanks
    Edited by: whitesox12 on Apr 3, 2008 9:46 PM

    [*!@#$%\^&()_+\[\]{}:;',./?~`]In a Java string literal, a backslash should be written as two consecutive backslashes.

  • Regular Expression, problem when the literals have content "I_"

    Hi,
    I guess this seems to be an Oracle bug/defect. If I am doing it wrongly, please let me know.
    I need to remove the "_VERSION" which comes at the last of a string column. For e.g, If the string is WINDOWS_XP_VERSION, then the output should be WINDOWS_XP.
    But if you run the below query,
    SELECT
    REGEXP_SUBSTR('AA_TEST_3_XI_VERSION', '\w+[^_VERSION]') t1,
    REGEXP_SUBSTR('AA_TEST_3_Xi_VERSION', '\w+[^_VERSION]') t2,
    REGEXP_SUBSTR('AA_TEST_3_XIA_VERSION', '\w+[^_VERSION]') t3
    FROM DUAL;
    T1 T2 T3
    AA_TEST_3_X AA_TEST_3_Xi AA_TEST_3_XIA
    1 rows selected
    It seems the issue exists only when I use "I_" and works fine with "i_". I checked with few other characters and it all worked fine.
    Any ideas? I am using 11g.
    Thanks,
    Sharmin

    Folks,
    Thanks for all your helps.
    MichaelS, REGEXO_SUBSTR (str, '(\w+)_VERSION$',1,1,null,1) works, but if any string which does not have "_VERSION", it would return NULL. Also, I had used'$' in my expression and missed to put it in the forum. I am sorry not to make it clear that my column can/cannot end with "_VERSION".
    hm, Thank you for making me understand how the regexp works. I thought if you do a '^' and supply a word, it would be considered together.
    What needs to be done for making negation for a specific word?
    WhiteHat,
    REGEXP_REPLACE is a better option. But in this case, it helps me the same way with the regular REPLACE function as my column will not contain any other '_VERSION' substring.
    I am going to use a regular replace function. select REPLACE('AA_TEST_3_XE_VERSION_VERSION','_VERSION','') substring from dual;
    Thanks once again for all your helps.
    Thanks,
    Sharmin

Maybe you are looking for

  • How to restore files after a Hard Drive crash?

    I just had my Hitachi 320 Gb Macbook HD crash (out of the blue started clicking when restarted, and the folder with question mark appeared). Good news is that I have a duplicate of the entire HD (using Retrospect "duplicate" function) from about a we

  • Will there be a update to fix the current problems of not opening

    Still cannot get itunes running.... Will they be creating an update to some how help to fix this issue

  • 'Unsupported color space' nonsense

    Hi all, I have Photoshop CS2, 9.0.2 and I'm still getting 'can't open file because it uses an unsupported color space' error when I try to edit a graphic object from Acrobat. Is there any way around this problem? Thanks!

  • Canon software update 2.4.1 - canon mp830

    when i installed the driver update onto my printer, it suddenly stopped wanting to print word documents... if this is the right forum, has anyone else had this problem?

  • Why does Numbers performance degrade?

    Hello everyone. I use Numbers often and continue to use 2.3.  I know that the speed of Numbers degrades with large data sets but why?  And are there tips on minimizing the impact? -DaverDee