• rsrvas (9/4/2015)


    Ignore earlier thread..

    "First A not followed by a B, C or D statement" means "A is present before B, C or D" need to ignore

    i am explaining again with simple text.This is almost same text as mentioned earlier. JUST "VEERNDAR" replaced with "VEERNDR"

    "AXNARENDR" replaced with "AXNRENDR" for getting expected result as i mentioned in the scenario (Its my mistake..i really sorry for this)

    TEXT 1: 'ABNAGENDRACSURENDRADJITHENDRAXNRENDRABVEERNDRAXDRMNDRAXRVINDRABNAGENDRACSURENDRADJITHEN'

    I break it in into substrings for understanding.when substrings concatenated will get TEXT

    ABNAGENDR

    ACSURENDR

    ADJITHENDR

    AXNRENDR

    ABVEERNDR

    AXDRMNDR

    AXRVINDR

    ABNAGENDR

    ACSURENDR

    ADJITHEN'

    From the above text1, I want to get “AXNRENDR”.(This is first substring which is having A other than "B" or "C" or "D",i.e AX)

    from the above substrings/TEXT, My concern is "A with B" or "A with C" or "A with D" occured N times before "A with X" (Here X is dynamic,It can be any character other than "B" or "C" or "D") looking code how to find “AXNARENDR”

    Based on this, it looks like you have just split this string up into sections, delimited by (but including the leading) "A". Except this is false for "ABNAGENDR", since it includes an "A".

    Next, if you look at the length of the strings that you supplied, they are various lengths - some are 8, and some are 9.

    So, what are the rules for determining how much of the string that you need to return?

    As was previously mentioned, the string "ABNAGENDR" breaks your rules of "A" not followed by B,C,D... it contains AGENDR, which meets that criteria.

    Please examine the rules that you have given to us so far, and fix the discrepancies. Too much information is missing for us to be able to really help you.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2