Indexing on regular expression seach for dynamic pattern

Hello All,
Would it be possible to create any index for regular expression search (REGEXP_LIKE) for 'dynamic' pattern?
If the pattern is static, then we can create FBI, but is there any way for dynamic patterns? Please advise.
Regards,
Hari

Thanks Dom, I have never used Oracle Text. Would it be possible to provide some sample code for above requirement.
Regards,
Hari

Similar Messages

  • Regular expression: check for the presence of special characters.

    I have the following requirement:
    I need to check for the presence of the following characters in a keyword: @, #, > if any of these characters are present, then they need to be stripped off, before going further. Please let me know the regular expression to check for these characters.

    I am trying to extend the same logic for the following characters:
    .,‘“?!@#%^&*()-~<>[]{}\+=`©® . here is the code fragment:
    Pattern kValidator = Pattern.compile("[\\.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]");
    Matcher kMatcher = kValidator.matcher(keyWord);
    if (kMatcher.find(0)) {
    keyWord = keyWord.replaceAll("[.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]", " ");
    }I get the following error. This error is from the weblogic command window. I dont understand these special characters.
    Error:
    28 Oct 2008 12:27:48 | INFO  | SearchController   | Exception while fetching search results in controller:Unclosed character class near index
    39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
    java.util.regex.PatternSyntaxException: Unclosed character class near index 39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
            at java.util.regex.Pattern.error(Pattern.java:1650)
            at java.util.regex.Pattern.clazz(Pattern.java:2199)
            at java.util.regex.Pattern.sequence(Pattern.java:1727)
            at java.util.regex.Pattern.expr(Pattern.java:1687)
            at java.util.regex.Pattern.compile(Pattern.java:1397)
            at java.util.regex.Pattern.<init>(Pattern.java:1124)
            at java.util.regex.Pattern.compile(Pattern.java:817)

  • How about the statement of regular expression like for this

    I what to get varians String array by one regular express for the statement like:
    ${user} like play ${game} in ${date}
    I want to get String[] as {"user","game","date"} by one regex, by str.split(regex). I tried many times but always fail to get the result I expected. May it be possible to meet the destination?
    thanks in advance
    Frederick

    why StringBuffer was using here?So one could split the pattern into multiple lines. But it just occurred to me that one could just use string concatenation, which would look better. I don't know why I bothered to use StringBuffefer.
    e.g.:
    String pattern =
        "^" +           // the start of a string
        "(dog)|(cat)" + // match either "dog" or "cat" at the start of the line
        "\\s*" +        // match an arbitrary amount of whitespace
        "$";            // but don't allow anything other than whitespace after dog or cat
    Pattern p = Pattern.compile(pattern);
    Pattern p = Pattern.compile("^(dog)|(cat)\\s*$");> isn't this look more simpler and better?
    In this case, yes. I was looking for a way to make regexps more explicit, with whitespace and comments, for more complicated cases.
    But those double quotes and plus signs add ugliness of their own, so a regexp would have to be pretty complex before it would be an improvement.

  • Regular Expression Search for Case Statement in VBA

    Hi,
    I'm having trouble trying to use regular expressions in a case statement. I have a CSV spreadsheet of a server's netstat output and am trying to plot everything into Visio. I have been able to do that, however I'm not trying to expand this capability and
    resuse the same code for many different servers. 
    I have the mainServer variable set as a Variant and in my current example it is set as "INTPXY001" (internal proxy server 001). I have tried different regex statements for the potential to have INTPXY001 - INTPXY999, EXTPXY001 - EXTPXY999, and
    SVCPXY001 - SVCPXY999 in place of the Case "INTPXY001", but nothing I have tried seems to work.
    '========================================
    Set mainServer As Variant
    Set AppVisio = CreateObject("visio.application")
    AppVisio.Visible = True
    AppVisio.Documents.AddEx "", visMSDefault, 0
    AppVisio.Documents.OpenEx "server_u.vss", visOpenRO + visOpenDocked
    mainServer = ActiveSheet.Cells(1, 2) 'sets mainServer to INTPXY001
    With AppVisio.ActiveWindow.Page
    Select Case mainServer
    Case "INTPXY001"
    .Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.ItemU("Proxy server"), 2.25, 9.25
    Case Else
    .Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.Item(("Server"), 2.25, 9.25
    End Select
    End With
    '========================================

    You cannot declare variables As Variant in VBScript. All variables in VBScript are implicitly variants.
    If you are asking about VBA (Visual Basic for Applications), then you're not asking in the correct forum.
    -- Bill Stewart [Bill_Stewart]

  • Help with regular expression to find a pattern in clob

    can someone help me writing a regular expression to query a clob that containts xml type data?
    query to find multiple occurrences of a variable string (i.e <EMPID-XX> - XX can be any number). If <EMPID-01> appears twice in the clob i want the result as EMPID-01,2 and if EMPID-02 appears 4 times i want the result as EMPID-02,4.

    with
    ofx_clob as
    (select q'~
    <EMPID>1
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>2
    < UNQID>123457
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>1
    < UNQID>123458
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    ~' ofx from dual
    select '<EMPID>' || to_char(ids) || '(' || to_char(count(*)) || ')' multi_empid
      from (select replace(regexp_substr(ofx,'<EMPID>\d*',1,level),'<EMPID>') ids
              from ofx_clob
            connect by level <= regexp_count(ofx,'<EMPID>')
    group by ids having count(*) > 1
    MULTI_EMPID
    <EMPID>1(2)
    with
    ofx_clob as
    (select q'~
    <EMPID>1
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>2
    < UNQID>123457
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>1
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>2
    < UNQID>123456
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    <EMPID>1
    < UNQID>123458
    < TIMESTAMP>...
    < ADDRINFO>
    < TITLE>^@~*
    < FIRST>ABCD
    < MI>
    < LAST>EFGH
    < ADDR1>ADDR1
    < ADDR2>^@~*
    < CITY>CITY
    ~' ofx from dual
    select '<EMPID>' || listagg(to_char(ids) || '(' || to_char(count(*)) || ')',',') within group (order by ids) multi_empid
      from (select replace(regexp_substr(ofx,'<EMPID>\d*',1,level),'<EMPID>') ids
              from ofx_clob
            connect by level <= regexp_count(ofx,'<EMPID>')
    group by ids having count(*) > 1
    MULTI_EMPID
    <EMPID>1(3),2(2)
    Regards
    Etbin
    Message was edited by: Etbin
    used listagg to report more than one multiple <EMPID>

  • Regular Expression Character Sets with Pattern and Matcher

    Hi,
    I am a little bit confused about a regular expressions I am writing, it works in other languages but not in Java.
    The regular expressions is to match LaTeX commands from a file, and is as follows:
    \\begin{command}([.|\n\r\s]*)\\end{command}
    This does not work in Java but does in PHP, C, etc...
    The part that is strange is the . character. If placed as .* it works but if placed as [.]* it doesnt. Does this mean that . cannot be placed in a character range in Java?
    Any help very much appreciated.
    Kind Regards
    Paul Bain

    In PHP it seems that the "." still works as a all character operator inside character classes.
    The regular expression posted did not work, but it does if I do:
    \\begin{command}((.|[\n\r\s])*)?\\end{command}
    Basically what I'm trying to match is a block of LaTeX, so the \\begin{command} and \\end{command} in LaTeX, not regex, although the \\ is a single one in LaTeX. I basically want to match any block which starts with one of those and ends in the end command. so really the regular expression that counts is the bit in the middle, ((.|[\n\r\s])*)?
    Am I right it saying that the "?" will prevent the engine matching the first and last \\bein and \\end in the following example:
    \\begin{command}
    some stuff
    \\end{command}
    \\begin{command}
    some stuff
    \\end{command}

  • How to use regular expression replace for this special characters?

    hi,
    I need to replace the below string, but i couldnt able to do if we use the special charaters '+', '$' . can anyone suggest a way to do this?
    select REGEXP_REPLACE('jan + feb 2008','jan + feb 2008', 'feb',1,0,'i') from dual
    anwers should be :- feb

    you should use escape character \.
    the regular expression will look like as follows:
    select REGEXP_REPLACE('jan + feb 2008','jan \+ feb 2008', 'feb',1,0,'i') from dual
    hope this is what you needed.
    cheers,
    Davide

  • Regular Expression Required for Checksum variable

    I am wanting to create a regular expression that extracts a variable checksum value (cs=) which is unique to a given server response string.
    The issue I am having is that a simple regex being name="cs" value="(.+?)" just does not work because there are 18 different checksum values being returned per session id/server response.
    So a simple regex just picks up any "cs" value and I guess gets confused since there are 18 different ones contained within the server response (all user related)
    What i need is a regex to use say this value from the server response (JONHONEYMAN%40YAHOO.COM) or any other unique value which is contained within the string response from the server then extract the cs (Checksum) value from that string and make it variable :)
    Here is the server response string:-
    "fp=220:1200:2977638312763704:: NO::P1200_EMAIL_ADDRESS,P1200_ORGANISATION_NAME,P1200_UCRN,P1200_ORG_ID,P1200_CALLING_PAGE:JONHONEYMAN%40YAHOO.COM%2C john%20Honeyman%2C260%2C220%2C1190&cs=336788D01EC6E80B1877B3EE982E8B2D8" >Select</td></tr
    can anyone help?
    Thanks

    You need an XML Parser.

  • Regular Expression Fails for Large Inputs

    I've got a problem on mu RegEx
    This is happenning for only when I input large files to it.
    My code is shown brlow...
    public static boolean isComment(String line) {
    Pattern pattern = Pattern.compile("((?:/\\*(?:--^*|(?:\\*+--*/--^--))*\\*+/)|(?:--.*))", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(line);
    return matcher.find();
    public static boolean isNewLine(String line) {
    Pattern pattern = Pattern.compile("^[\\s\n]+$", Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(line);
    return matcher.find();
    public static boolean isKeyWord(String line) {
    Pattern pattern = Pattern.compile("^[ \t\n]*(DECLARE|PACKAGE|TRIGGER|PROCEDURE|TYPE|CREATE|ALTER)", Pattern.CASE_INSENSITIVE);^
    ^Matcher matcher = pattern.matcher(line);^
    ^return matcher.find();^
    ^}^
    ^public static String isCTExists(String regEx, String line) {^
    ^Pattern pattern = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);^
    ^Matcher matcher = pattern.matcher(line);^
    ^String s = line;^
    ^while (matcher.find()) {^
    ^s = matcher.replaceAll(replaceCTStr(matcher.group()));^
    ^}^
    ^if (s.equals(""))^
    ^return line;^
    ^else^
    ^return s;^
    ^}^
    ^public static String replaceCTStr(String line) {^
    ^Pattern pattern = Pattern.compile("\\)", Pattern.CASE_INSENSITIVE);^
    ^Matcher matcher = pattern.matcher(line);^
    ^return matcher.replaceFirst("\\)\n/");^
    ^}^
    ^public static String isExists(String regEx, String line) {^
    ^Pattern pattern = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);^
    ^Matcher matcher = pattern.matcher(line);^
    ^String s = line;^
    ^while (matcher.find()) {^
    ^s = matcher.replaceAll(replaceStr(matcher.group()));^
    ^}^
    ^if (s.equals(""))^
    ^return line;^
    ^else^
    ^return s;^
    ^}^
    ^public static String replaceStr(String line) {^
    ^Pattern pattern = Pattern.compile("END[ \t]*;", Pattern.CASE_INSENSITIVE);^
    ^Matcher matcher = pattern.matcher(line);^
    ^return matcher.replaceFirst("END;\n/");^
    ^}^
    ^public static boolean isHaveEnding(String line) {^
    ^Pattern pattern = Pattern.compile("(END[ \t\"A-Za-z_]*;[ \t\n]*)$|([\\)]{1}[ \t\n]*)$", Pattern.CASE_INSENSITIVE);^
    ^Matcher matcher = pattern.matcher(line);^
    ^return matcher.find();^
    ^}^
    ^public static String checkCTMid(String regEx, String line) {^
    ^Pattern pattern = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);^
    ^Matcher matcher = pattern.matcher(line);^
    ^boolean notEnded = false;^
    ^String s = "";^
    ^String temp = "";^
    ^while (matcher.find()) {^
    ^if (matcher.group() != null) {^
    ^if (isComment(matcher.group())) {^
    ^s += matcher.group();^
    ^} else if (isNewLine(matcher.group())) // all the new line characters handled here...^
    ^{^
    ^s += matcher.group();^
    ^continue;^
    ^}^
    ^}^
    ^if (matcher.group(1) != null && !matcher.group(1).equals("")) {^
    ^if (notEnded && isKeyWord(matcher.group(1))) {^
    ^s += "\n/";^
    ^notEnded = false;^
    ^} else^
    ^notEnded = false;^
    ^temp = isCTExists("(\\)[ \n\t\r]*--;--^(?:DECLARE|PACKAGE|TRIGGER|PROCEDURE|TYPE|CREATE|ALTER))", matcher.group(1));
    temp = isExists("(END;[ \n\t\r]*[^/](?:DECLARE|PACKAGE|TRIGGER|PROCEDURE|TYPE|CREATE|ALTER))", temp);
    s += temp;+
    +if (isHaveEnding(matcher.group(1))) {+
    +notEnded = true;+
    +}+
    +}+
    +}+
    +return s;+
    +}+
    +public static void main(String[] args) {+
    +String str = readFile("test.txt");+
    +System.out.println("Read Compleate");+
    +String strWithoutComments = checkCTMid( "(?:/\\*(?:--^*--|(?:\\*+--^/*--))*\\*+/)|(?:--.*)|((?:--^/-++|/(?!\\*)|-(?!-))*+)" , str ); //ok^--
    --^String strWithoutbSlashMiddleEndForCT = isCTExists( "(\\)[ \t\n\r]*--;/--^--$)" , strWithoutComments);
    String strWithoutbSlashMiddleEnd = isExists( "(END;[ \t\n\r]*--^/--$)" , strWithoutbSlashMiddleEndForCT);
    System.out.println(strWithoutbSlashMiddleEnd);
    {code}
    This code is currently parse SQL statements and add '/' characters finding the missed places.
    When i give this 'test.txt' as a long file (with 10000 LOC) gives belov error.
    *Exception in thread "main" java.lang.StackOverflowError*
    * at java.lang.Character.codePointAt(Character.java:2335)*
    * at java.util.regex.Pattern$BitClass.match(Pattern.java:2873)*
    * at java.util.regex.Pattern$Branch.match(Pattern.java:4530)*
    * at java.util.regex.Pattern$GroupHead.match(Pattern.java:4570)*
    * at java.util.regex.Pattern$Loop.match(Pattern.java:4697)*
    * at java.util.regex.Pattern$GroupTail.match(Pattern.java:4629)*
    * at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)*
    * at java.util.regex.Pattern$Branch.match(Pattern.java:4530)*
    * at java.util.regex.Pattern$GroupHead.match(Pattern.java:4570)*
    * at java.util.regex.Pattern$Loop.match(Pattern.java:4697)*
    * at java.util.regex.Pattern$GroupTail.match(Pattern.java:4629)*
    * at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)*
    * at java.util.regex.Pattern$Branch.match(Pattern.java:4530)*
    * at java.util.regex.Pattern$GroupHead.match(Pattern.java:4570)*
    * at java.util.regex.Pattern$Loop.match(Pattern.java:4697)*
    * at java.util.regex.Pattern$GroupTail.match(Pattern.java:4629)*
    * at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)*
    * at java.util.regex.Pattern$Branch.match(Pattern.java:4530)*
    * at java.util.regex.Pattern$GroupHead.match(Pattern.java:4570)*
    * at java.util.regex.Pattern$Loop.match(Pattern.java:4697)*
    * at java.util.regex.Pattern$GroupTail.match(Pattern.java:4629)*
    * at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)*
    * at java.util.regex.Pattern$Branch.match(Pattern.java:4530)*
    * at java.util.regex.Pattern$GroupHead.match(Pattern.java:4570)*
    * at java.util.regex.Pattern$Loop.match(Pattern.java:4697)*
    * at java.util.regex.Pattern$GroupTail.match(Pattern.java:4629)*
    * at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)*
    * at java.util.regex.Pattern$Branch.match(Pattern.java:4530)*
    * at java.util.regex.Pattern$GroupHead.match(Pattern.java:4570)*
    * at java.util.regex.Pattern$Loop.match(Pattern.java:4697)*
    * at java.util.regex.Pattern$GroupTail.match(Pattern.java:4629)*
    * at java.util.regex.Pattern$BitClass.match(Pattern.java:2876)*
    This is not hapenning for small files.
    Can anyone help!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Let's see if I can get this to display as intended: {noformat}(?:/\*(?:[^*]|(?:\*+[^/*]))*\*+/)|(?:--.*)|((?:[^/-]++|/(?!\*)|-(?!-))*+){noformat} Okay, when I try that regex (in EditPad Pro, against the source code of this web page), I see this result: The second alternative, {noformat}(?:--.*){noformat} matches anything from a double hyphen to the end of that line, and the third alternative: {noformat}((?:[^/-]++|/(?!\*)|-(?!-))*+){noformat} matches everything else (up to the next double hyphen, that is). These pages happen to contain a lot of SGML comments, so there are plenty of double hyphens to match. In a large document with only a few double hyphens, it would be easy to blow the stack trying to find the next stopping point.
    What exactly is the isComment() method supposed to do? Are you trying to match a line that consists entirely of a comment, or just a line that contains a comment? And how exactly do you define a comment?

  • Regular Expression needed for a password validator

    Business Rules:
    Password must be at least 8 characters
    Contain at least 1 non alpha character and no spaces.
    Here is what I got so far:
      String regex = "(?=^.{8,}$)((?!.*\\s)(?=.*[^a-zA-Z])(?=.*[a-zA-Z0-9]))^.*$";
            String [] password = new String [7];
            password [0] = "H@ffman1";
            password [1] = "hoffman1";
            password [2] = "Hoffman1";
            password [3] = "Hoffman 1";
            password [4] = "hoffman 1";
            password [5] = "hoffmans";
            password [6] = "123456789";
            for(int i=0; i<password.length; i++){
                Pattern pattern = Pattern.compile(regex.trim());
                Matcher matcher = pattern.matcher(password);
    System.out.println(password[i] + " == " + matcher.matches());
    }Output:
    H@ffman1 == true
    hoffman1 == true
    Hoffman1 == true
    Hoffman 1 == false
    hoffman 1 == false
    hoffmans == true // (This is a problem)
    123456789 == true // (This is a problem)

    YoungWinston wrote:
    prometheuzz wrote:
    which is pretty much what our OldWinston suggested...Actually, I was thinking more along the lines of
    System.out.println( password.matches("^[^\\s]{8,}$")
    && password[i].matches("[^a-zA-Z]") );
    (I may have got the number of backslahes wrong; 'always forget that stuff).Ah, I see. But you probably meant:
    password.matches(".*[^a-zA-Z].*")and they're cryptic enough as it is :-).
    Cryptic? Nah...

  • Regular Expression match for BOM char .

    i am trying to match BOM char in file with regex but \\ufeff seem to be not working .
    please suggest solution on this

    This line               String srcStr = new String(b);will only produce the String you expect if the BOM bytes can be converted to characters under your default character encoding. They probably can't.
    I use this class
    public class BOMStripperInputStream extends PushbackInputStream
        public static final int[][] BOMS =
                0x00, 0x00, 0xFE, 0xFF
                0xFF, 0xFE, 0x00, 0x00
                0x2B, 0x2F, 0x76, 0x38
                0x2B, 0x2F, 0x76, 0x39
                0x2B, 0x2F, 0x76, 0x2B
                0x2B, 0x2F, 0x76, 0x2F
                0xDD, 0x73, 0x66, 0x73
                0xEF, 0xBB, 0xBF
                0x0E, 0xFE, 0xFF
                0xFB, 0xEE, 0x28
                0xFE, 0xFF
                0xFF, 0xFE
        static private int testForBOM(int[] bom, int[] bytes)
            for (int index = 0; index < bom.length; index++)
                if (bom[index] != bytes[index])
                    return 0;
            return bom.length;
        public BOMStripperInputStream(InputStream is) throws IOException
            super(is, 4);
            final int[] bytes =
                read(), read(), read(), read()
            int count = 0;
            for (int[] bom : BOMS)
                count = testForBOM(bom, bytes);
                if (count != 0)
                    break;
            for (int index = bytes.length - 1; index >= count; index--)
                if (bytes[index] != -1)
                    unread(bytes[index]);
    }to get rid of a BOM .

  • Correct regular expression format for hub transport rule??

    I want to create a regex such that it tests for two words with a space between them.
    Exchange says /abc(\s)def/ig -- abc def or ABC DEF will pass the test -- Exchange says /mls(\s)secure/ig regex won't work.
    How do I write the regex so it works in Exchange 2010??
    Thank you, Tom

    Hi Tom,
    As Amit said, you can test the regex via EMS.
    I have some tests in my environment using Exchange 2010. "abc def" -match "/abc(\s)def/ig" is false. Also, "ABC DEF" -match "/abc(\s)def/ig" is false. You can use the "^\w+\s\w+$" regex to test for two words with a space between them.
    Hope it helps.
    Best regards,
    Amy Wang
    TechNet Community Support

  • Regular expression help for matching numbers

    Hi,
    I want a exact match of either 9 digits or 12 digits, my query should give "No Match Found" as the input value is actually 10 digit
    select case when regexp_like(regexp_replace( ' 123 4567 890', ' ' ), '^([0-9]{9})|([0-9]{12})$')
    then 'Match Found'
    else 'No Match Found'
    end as test
    from dual;
    Need help, as I must be doing something very basic thing, wrong.
    Regards,
    Ash

    Remove 2 brackets:
    SQL> select case when regexp_like(regexp_replace( ' 123 4567 890', ' ' ), '^([0-9]{9}|[0-9]{12})$')
      2  then 'Match Found'
      3  else 'No Match Found'
      4  end as test
      5  from dual;
    TEST
    No Match Found
    SQL> select case when regexp_like(regexp_replace( ' 123 4567 89', ' ' ), '^([0-9]{9}|[0-9]{12})$')
      2  then 'Match Found'
      3  else 'No Match Found'
      4  end as test
      5  from dual;
    TEST
    Match Found
    SQL>

  • Regular Expression Query for SQL

    Hi,
    I am working on SQL server and there is a requirement of separating street name and street number. 
    I tried using regexp_substr but not able to do it perfectly.
    Here are some sample names which need cleansing
    Full name 
    street name
    street no
    Bahnhofplatz 1 / Werkstatt
    Bahnhofplatz
    1 / Werkstatt
    Reinacherstr. 149/151
    Reinacherstr.
    149/151
    Kosuth UCA 7/A
    Kosuth UCA
    7/A
    Route des Jeunes 9 / 6 ème
    Route des Jeunes
    9 / 6 ème
    L'Arcadie / Route de Moudon
    L'Arcadie / Route de Moudon
    null
    Hofstetten 206
    Hofstetten
    206
    Rgds
    Amitabh

    try this
    DECLARE @test TABLE (address VARCHAR(50))
    INSERT INTO @test values ('Bahnhofplatz 1 / Werkstatt')
    ,('Reinacherstr.149 / 151')
    ,('Kosuth UCA 7 / A')
    ,('Moudon')
    ,('L''Arcadie / Route de')
    SELECT
    Address,
    CASE
    WHEN patindex('%[0-9]%',address) = 0 then address else substring(address,0,patindex('%[0-9]%',address)) end col1,
    CASE WHEN patindex('%[0-9]%',address) >0 then SUBSTRING(address,patindex('%[0-9]%',address),LEN(address)) end col2
    from @test
    Address col1
    col2
    Bahnhofplatz 1 / Werkstatt
    Bahnhofplatz 1 / Werkstatt
    Reinacherstr.149 / 151
    Reinacherstr. 149 / 151
    Kosuth UCA 7 / A
    Kosuth UCA 7 / A
    Moudon Moudon
    NULL
    L'Arcadie / Route de
    L'Arcadie / Route de
    NULL
    --Prashanth

  • Regular Expression for Match Pattern (string) Function

    I need to find a variable length string enclosed by brackets and
    within a string. Can't seem to get the regular expression right for
    the Match Pattern function. I'm able to get the job done using the
    Token function, but it's not as slick or tight as I'd like. Does
    anybody out there have the expression for this?

    Jean-Pierre Drolet wrote in message news:<[email protected]>...
    > The regular expression is "\[[~\]]*\]" which means:
    > look for a bracket "\[" (\ is the escape char)
    > followed by a string not containing a closing bracket "[~\]]*"
    > followed by a closing bracket "\]". The match string include the
    > brackets
    >
    > You can also read "Scan from String" with the following format:
    > "%[^\[]\[%[^\[\]]" and read the 2nd output. The brackets are removed
    > from the scanned string.
    Thanks, Jean_Pierre
    I did some more experimenting after posting and found that \[.*\] also
    works with the match pattern function. Thanks for your input.
    sm

Maybe you are looking for