Help!!!!! Regular Expressions!!

I am trying to use Regular Expressions, for parsing. For that the pakage required is
java.util.regex.*;
I am also using the import statement in a sample code. But compiling it, gives an error,
ERRORS:
Replacement.java:6: package java.util.regex does not exist
import java.util.regex.*;
^
I have also set the path to C:\jdk1.4\bin
I have also set the classpath to C:\jdk1.4\lib
I don't know, Why it doesn't recognise the java.util.regex package
please help!!
gaurav_k1

Have you checked if the regex package is part of the
JDK1.4? I can't find it. What classes does it
implement?Yeah, since 1.4
http://java.sun.com/j2se/1.4/docs/api/java/util/regex/package-summary.html
I'm not sure what the original problem could be, possibly using a previously installed jre? If you had one previously installed, check the classpaths and uninstall any old jre (some forget that thinking they only need to remove the jdk). Could you give us anymore hints?

Similar Messages

  • Please Help: Regular Expression Gives Stack Overflow

    Regular Expressions are the bane of my existence. I hate them and everyone seem to have their own slightly different syntax. Anyhow, I have a problem with the below code, as it gives me a stack overflow:
         public static void main(String[] args) throws IOException {
              System.out.print(parseText(readTextFile("c:\\file.txt"))); // the input file is displayed below
    // simple method to test that the regular expression can be matched. it works for simple expression, but not the one below
    // this is the code that causes stack overflow
         public static String parseText(String inputString) {
               Pattern p = Pattern.compile("<tr>(\\s)*<td class = 'abc[0-9]*(\\s)*'>(.|\\s)+</nobr>(\\s)+</td>(\\s)+</tr>");
               Matcher m = p.matcher(inputString);
               m.find();
               return m.group();
    // this method just reads in a text file and returns a String with the whole content
    // this works, but is posted here for completeness
        public static String readTextFile(String filePath)
            File file = new File(filePath);
              StringBuffer contents = new StringBuffer();
              BufferedReader reader = null;
              try {
                   reader = new BufferedReader(new FileReader(file));
                   String text = null;
                   // repeat until all lines is read
                   while ((text = reader.readLine()) != null) {
                        contents.append(text).append(
                                  System.getProperty("line.separator"));
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   try {
                        if (reader != null) {
                             reader.close();
                   } catch (IOException e) {
                        e.printStackTrace();
              return contents.toString();
        }Below is the content of what I'm feeding the above code as file.txt that results in an error.
       <tr>
            <td class = 'abc1 '>
                <b><a href = 'http://somedomain.com/bla.html' class="a1"> 
                    something 1
                </a></b>   
            </td>
            <td class = 'abc1 '>
                cars 
            </td>
            <td class = 'abc1 ' nowrap align="center">
                ibm
            </td>
            <td class = 'abc1 '>
                <a href = 'http://somedomain.com/bla2.html'>
                    Features
                </a>
            </td>
            <td class = 'abc1 '>
                <nobr>Feb 5, 2009</nobr>
            </td>
        </tr>
       <tr>
            <td class = 'abc1 '>
                <b><a href = 'http://somedomain.com/bla2.html' class="b1"> 
                    something 2
                </a></b>   
            </td>
            <td class = 'abc1 '>
                car 
            </td>
            <td class = 'abc1 ' nowrap align="center">
                sun
            </td>
            <td class = 'abc1 '>
                <a href = 'http://somedomain.com/bla3.html'>
                    Features
                </a>
            </td>
            <td class = 'abc1 '>
                <nobr>Feb 5, 2009</nobr>
            </td>
        </tr>
        Here is some lines from the stack overflow output:
    Exception in thread "main" java.lang.StackOverflowError
         at java.util.regex.Pattern$GroupTail.match(Unknown Source)
         at java.util.regex.Pattern$BranchConn.match(Unknown Source)
         at java.util.regex.Pattern$CharProperty.match(Unknown Source)
         at java.util.regex.Pattern$Branch.match(Unknown Source)
         at java.util.regex.Pattern$GroupHead.match(Unknown Source)However, if I feed the program this shorter version of the input it works (it matches only once and is just the top portion of the original file.txt):
       <tr>
            <td class = 'abc1 '>
                <b><a href = 'http://somedomain.com/bla.html' class="a1"> 
                    something 1
                </a></b>   
            </td>
            <td class = 'abc1 '>
                cars 
            </td>
            <td class = 'abc1 ' nowrap align="center">
                ibm
            </td>
            <td class = 'abc1 '>
                <a href = 'http://somedomain.com/bla2.html'>
                    Features
                </a>
            </td>
            <td class = 'abc1 '>
                <nobr>Feb 5, 2009</nobr>
            </td>
        </tr>I did some google searches, but the problem appears to do with how I crafted my regular expression. The solution didn't make sense to me.... Anyone help me please as I spent a big portion of the day already!

    @flounder,
    Wow, hold your horses...
    That comment was meant to denote my level of frustration with this since I had spent a large portion of the day trying to figure it out. It was not intended to designate my issue or time as more important than others.
    I certainly appreciate any help considering nobody is being compensated in any way for helping me.
    @jschell,
    This is intended to be used as a one time deal to automate recapturing data we no longer have in a non-HTML format.
    I appreciate the suggestion though.
    @JoachimSauer
    Thank you for all your help. I appreciate it!

  • Help: Regular Expression question??

    Hello,
    How can I extract the following content using Java Regular expression?
    <tr bgcolor="#333333">
         <td class="title" colspan="4" height="18"> <b>SUPER_1</b> - SUPER_2</td>
    </tr>
    <tr bgcolor="#333333">
         <td class="match-light" width="45" height="18"> </td>
         <td class="match-light" colspan="3" width="286" align="right">March 19 </td>
    </tr>
    <tr>
         <td colspan="4" height="1"></td>
    </tr>
    <tr bgcolor="#cfcfcf">
         <td width="45" height="18"> FT</td>
         <td width="118" align="right">SUPER_3</td>
         <td width="50" align="center"><a class="scorelink" target="details" onclick="showDetails();">999 - 888</a></td>
         <td width="118">SUPER_4</td>
    </tr>From the above contents, How can I define a regular expression for extract the "*SUPER_1*", "*SUPER_2*", "*March 19*", "*SUPER_3*", "*999*", "*888*" and "*SUPER_4*" ????
    Please help.
    Best regards,
    Eric

    Kayaman wrote:
    Why not use a better way than regex, like an actual HTML parser (or XML if you have it well-formed)? People seem to love parsing (or rather, asking help how to parse) HTML with regex for some unknown reason.Indeed.
    Read this (hilarious):
    http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

  • Help: Regular Expression - 2

    Hi,
    Good Day to All..
    Database : 11g
    Col1
    Louie: The Complete First Season [2 Discs] [DVD/Blu-ray]
    Snow White and the Seven Dwarfs [Blu-ray/DVD] - Bonus Disc
    About Last Night... [WS] [Blu-ray]
    High3:[Extended] [3 Discs] [Includes Digital Copy] [BR]
    High4: The [Extended] [3 Discs] [BR]
    Output should show in the below format:-
    Col1
    Louie: The Complete First Season [Blu-ray]
    Snow White and the Seven Dwarfs [Blu-ray] - Bonus Disc
    About Last Night...[Blu-ray]
    High3: [BR]
    High4: The [BR]
    Even if my column contains [Blu-ray/DVD] or [DVD/Blu-ray], i have to replace [Blu-ray] and for other [xxx] braces section has to be removed.
    Query which used and worked out for first three column values :-
    SELECT col1,
      REPLACE(regexp_replace (regexp_replace (col1, '\[.*?Blu.*?ray.*?\]' , '{Blu-ray}' , 1 , 1 ,'i') ,'\[.*?\]') , '{Blu-ray}' , '[Blu-ray]')
      new_col1
    FROM tablename
    WHERE col1 LIKE '%Blu-ray/DVD%' OR col1 LIKE '%[DVD/Blu-ray]%'
    OR col1 LIKE '%[Blu-ray]%'
    OR col1 LIKE '%[BR]%'Need the solution for [BR] column values.
    Thanks ...

    One way is to keep nesting your regexps:
    SQL> with tab1 as
      2  (
      3  select  'The Complete Season Three [3 Discs] [Blu-ray] - Disc 1' col1 from dual union all
      4  select  'Another movie [5 Discs] [DVD/blu-ray] - Disc 1' col1 from dual union all
      5  select '(500) Days of Summer [2 Discs] [Includes Digital Copy] [BLURAY/DVD]' col1 from dual union all
      6  select 'High3:[Extended] [3 Discs] [Includes Digital Copy] [BR]' col1 from dual union all
      7  select 'High4: The [Extended] [3 Discs] [BR]' col1 from dual
      8  )
      9  select
    10  replace(
    11     replace(
    12        regexp_replace(
    13           regexp_replace(
    14              regexp_replace(
    15                 col1,
    16                 '\[.*?Blu.*?ray.*?\]', '{Blu-ray}', 1, 1, 'i'
    17              ),
    18              '\[BR\]', '{BR}', 1, 1, 'i'
    19           ),
    20           '\[.*?\]'
    21        ),
    22        '{Blu-ray}',
    23        '[Blu-ray]'
    24     ),
    25     '{BR}',
    26     '[BR]'
    27  ) test2
    28  from tab1
    29  ;
    TEST2
    The Complete Season Three [Blu-ray] - Disc 1
    Another movie [Blu-ray] - Disc 1
    (500) Days of Summer [Blu-ray]
    High3:   [BR]
    High4: The   [BR]The regexp expression in line 16 take [<anything>Blu<anything>ray<anything>] and turn it into '{Blu-ray}. (The original from your last question.)
    The regexp in line 18 take [BR] and turn it into {BR} (again the 'i' parameter makes it case in-sensitive so it also catches [Br] [br] and [bR].)
    Then line 20 removes all other [] bracket expressions.
    Line 22-23 turns {Blu-ray} back into [Blu-ray] and 25-26 turns {BR} into [BR].
    You can keep nesting this.
    The trick is first to turn [something] into {something}, before you remove all other [], and then turn the {something} into [something].
    As with the [<anything>Blu<anything>ray<anything>] expression you can also catch the data even if Blu-ray is not spelt exactly right.
    And if you also find cases with for instance [BR/DVD] and wish to turn that into [BR], then you add some suitable .*? in line 18 the same way as line 16 ;-)
    Maybe you should consider selecting all bracket expressions in your data in order to get an overview of how many different bracket expression you have to nest?
    Edit:
    Couldn't resist trying that ;-)
    SQL> with tab1 as
      2  (
      3  select  'The Complete Season Three [3 Discs] [Blu-ray] - Disc 1' col1 from dual union all
      4  select  'Another movie [5 Discs] [DVD/blu-ray] - Disc 1' col1 from dual union all
      5  select '(500) Days of Summer [2 Discs] [Includes Digital Copy] [BLURAY/DVD]' col1 from dual union all
      6  select 'High3:[Extended] [3 Discs] [Includes Digital Copy] [BR]' col1 from dual union all
      7  select 'High4: The [Extended] [3 Discs] [BR]' col1 from dual
      8  )
      9  select
    10  bracket_exp,
    11  count(*) cnt
    12  from (
    13     select
    14     regexp_substr(tab1.col1,'\[.*?\]',1,r.r) bracket_exp
    15     from tab1
    16     cross join (
    17        select level r
    18        from dual
    19        connect by level <= 10
    20     ) r
    21  )
    22  where bracket_exp is not null
    23  group by bracket_exp
    24  order by cnt desc
    25  ;
    BRACKET_EXP                                                                CNT
    [3 Discs]                                                                    3
    [Extended]                                                                   2
    [BR]                                                                         2
    [Includes Digital Copy]                                                      2
    [Blu-ray]                                                                    1
    [5 Discs]                                                                    1
    [2 Discs]                                                                    1
    [BLURAY/DVD]                                                                 1
    [DVD/blu-ray]                                                                1
    9 rows selected.This is just a piece of one-off code to help you analyze your data and discover which bracket expressions you need to care about.
    It is not necessarily optimal, and I have assumed there will be no more than 10 bracket expressions (you could raise that number if you wish.)
    Possibly you might consider:
    upper(regexp_substr(tab1.col1,'\[.*?\]',1,r.r)) bracket_expto count as identical those bracket expressions that are alike except for lower/upper-case.
    Edited by: Kim Berg Hansen on Sep 14, 2011 10:18 AM

  • Need Help - regular expression

    Hello,
    I am doing one kind of parsing in which my input string will be
    INPUT : hi*< img src='ani.gif'>*
    Desired output : hi
    Means I want to write a reg exp for omitting text in bold shown in above.
    thanks
    Aniruddha

    prometheuzz wrote:
    jverd wrote:
    I continue to be disappointed, but not surprised, at how people are either unable or can't be bothered to communicate their problem requirements, and to consider that there might be cases that may or may not match the one example they give and that need to be accounted for.Yes, I know the feeling. And when asked for clarification, you frequently get just one other example leaving the remaining 1000 cases to guess for the people answering the question.Yup.
    OP: i need regex.......... to turn numbers into X........
    Us: Provide more detailed requirements, and examples of what would and wouldn't get changed.
    OP: "a 1" --> "a X", but "a b" --> "a b" .......bcos...... there r no numbers.
    Us: See previous reply. More detail. Examples.
    OP: ok i thot u guyzz were pros r sumtin so i wudnt have 2 xpln evrthng but whatevs.....lol......... so like i have letters..... and numbers..... n if therz a number i wan 2 mak it a x, like a 1 becomz a x n b 2 bcoms b x......... do u clr now......... pls give me teh codez........ or maybee dis prob 2 hard for u guyzzz..... i chalegne u to do it.....
    Us, deciding it's not worth it to try to explain that his two examples are identical, that his "explanation" added no new information, that he needs to specify whether each digit becomes and X or each numerical token, whether numbers that are connected to words without an intervening space get converted, etc.:
    [:headdesk:|http://www.geocities.com/darrylbu/images/headdesk.gif]
    [:headdesk:|http://www.geocities.com/darrylbu/images/headdesk.gif]
    [:headdesk:|http://www.geocities.com/darrylbu/images/headdesk.gif]
    [:headdesk:|http://www.geocities.com/darrylbu/images/headdesk.gif]
    [:headdesk:|http://www.geocities.com/darrylbu/images/headdesk.gif]
    [:headdesk:|http://www.geocities.com/darrylbu/images/headdesk.gif]

  • Help in regular expression matching

    I have three expressions like
    1) [(y2009)(y2011)]
    2) [(y2008M5)(y2011M3)] or [(y2009M5)(y2010M12)]
    3) [(y2009M1d20)(y2011M12d31)]
    i want regular expression pattern for the above three expressions
    I am using :
    REGEXP_LIKE(timedomainexpression, '???[:digit:]{4}*[:digit:]{1,2}???[:digit:]{4}*[:digit:]{1,2}??', 'i');
    but its giving results for all above expressions while i want different expression for each.
    i hav used * after [:digit:]{4}, when i am using ? or . then its giving no results. Please help in this situation ASAP.
    Thanks

    I dont get your question Can you post your desired output? and also give some sample data.
    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Help in query using regular expression

    HI,
    I need a help to get the below output using regular expression query. Please help me.
    SELECT REGEXP_SUBSTR ('PWRPKG(P/W+P/L+CC)', '[^+]+', 1, lvl) val, lvl
    FROM DUAL,(SELECT LEVEL lvl FROM DUAL
    CONNECT BY LEVEL <=(SELECT MAX ( LENGTH ('PWRPKG(P/W+P/L+CC)') - LENGTH (REPLACE ('PWRPKG(P/W+P/L+CC)','+',NULL))+ 1) FROM DUAL));
    I need the output as
    correct result:
    ==============
    val lvl
    P/W 1
    P/L 2
    CC 3
    But i tried the above it is not coming the above result. Please help me where i did a mistake.
    Thanks in advance

    Frank gave you a solution in your other thread. You could simplify it if you are on 11g:
    SQL> select * from table_x
      2  /
    TXT
    TECHPKG(INTELLI CC+FRT SONAR)
    PWRPKG(P/W+P/L+CC)
    select  txt,
            regexp_substr(
                          txt,
                          '(.*\()*([^+)]+)',
                          1,
                          column_value,
                          null,
                          2
                         ) element,
            column_value element_number
      from  table_x,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= regexp_count(txt,'\+') + 1
                       as sys.OdciNumberList
      order by rowid,
               column_value
    TXT                                      ELEMENT    ELEMENT_NUMBER
    TECHPKG(INTELLI CC+FRT SONAR)            INTELLI CC              1
    TECHPKG(INTELLI CC+FRT SONAR)            FRT SONAR               2
    PWRPKG(P/W+P/L+CC)                       P/W                     1
    PWRPKG(P/W+P/L+CC)                       P/L                     2
    PWRPKG(P/W+P/L+CC)                       CC                      3
    SQL>  SY.

  • Query help in regular expression

    Hi all,
    SELECT * FROM emp11
    WHERE INSTR(ENAME,'A',1,2) >0;
    Please let me know the equivalent query using regular expressions.
    i have tried this after going through oracle regular expressions documentation.
    SELECT * FROM emp11
    WHERE regexp_LIKE(ename,'A{2}')
    Any help in this regard would be highly appreciated .
       Thanks,
    P Prakash

    please go here
    Introduction to regular expressions ...
    Thanks,
    P Prakash

  • Need help with regular expression

    I'm trying to use the java.util.regex package to extract URLs from html files.
    The URLs that I am interested in extracting from the HTML look like the following:
    <font color="#008000">http://forum.java.sun.com -
    So, the URL is always preceeded by:
    <font color="#008000">
    and then followed by a space character and then a hyphen character. I want to be able to put all these URLs in a Vector object. This doesn't seem like it should be too difficult but for some reason I can't get anywhere with it. Any help would be greatly appreciated. Thanks!

    hi gupta am not sure of the java syntax but i can tell u about the regular expression...try this....
    <font color="#008000">(http:\/\/[a-zA-Z0-9.]+) [-]
    i dont know the java methods to call...just the reg exp...
    Sanjay Acharya

  • Help regarding regular expression

    HI All ,
    Please see the following string
    String s = "IF ((NOT NUM4 IS ALPHABETIC ) AND NUM3 IS ALPHABETIC-UPPER AND (NUM5 IS GREATER OR EQUAL TO 3) AND (NUM5 IS NOT GREATER THAN 3) AND (NUM3 GREATER THAN 46) AND (NUM5 GREATER THAN NUM3) OR NUM3 LESS THAN 78) .";
    My problem is: i want to capture the part of this line which contains "ALPHABETIC ,ALPHABETIC-UPPER for ex :NOT NUM4 IS ALPHABETIC , NUM3 IS ALPHABETIC-UPPER.from that I have to capture the word num4 , num3 which are in these phrases only ;from the whole string whereever it exists along with the phrase,Can any one help me out by suggesting something.num4 and num3 are variable names

    I suspect you're right, Sabre, but I can't resist...
    import java.util.regex.*;
    * A rewriter does a global substitution in the strings passed to its
    * 'rewrite' method. It uses the pattern supplied to its constructor, and is
    * like 'String.replaceAll' except for the fact that its replacement strings
    * are generated by invoking a method you write, rather than from another
    * string. This class is supposed to be equivalent to Ruby's 'gsub' when given
    * a block. This is the nicest syntax I've managed to come up with in Java so
    * far. It's not too bad, and might actually be preferable if you want to do
    * the same rewriting to a number of strings in the same method or class. See
    * the example 'main' for a sample of how to use this class.
    * @author Elliott Hughes
    public abstract class Rewriter
      private Pattern pattern;
      private Matcher matcher;
       * Constructs a rewriter using the given regular expression; the syntax is
       * the same as for 'Pattern.compile'.
      public Rewriter(String regularExpression)
        this.pattern = Pattern.compile(regularExpression);
       * Returns the input subsequence captured by the given group during the
       * previous match operation.
      public String group(int i)
        return matcher.group(i);
       * Overridden to compute a replacement for each match. Use the method
       * 'group' to access the captured groups.
      public abstract String replacement();
       * Returns the result of rewriting 'original' by invoking the method
       * 'replacement' for each match of the regular expression supplied to the
       * constructor.
      public String rewrite(CharSequence original)
        this.matcher = pattern.matcher(original);
        StringBuffer result = new StringBuffer(original.length());
        while (matcher.find())
          matcher.appendReplacement(result, "");
          result.append(replacement());
        matcher.appendTail(result);
        return result.toString();
      public static void main(String[] args)
        String s = "IF ((NOT NUM4 IS ALPHABETIC ) " +
                    "AND NUM3 IS ALPHABETIC-UPPER " +
                    "AND (NUM5 IS GREATER  OR EQUAL TO 3) " +
                    "AND (NUM5 IS NOT GREATER THAN 3) " +
                    "AND (NUM3 GREATER THAN 46) " +
                    "AND NUM645 IS ALPHABETIC " +
                    "AND (NUM5 GREATER THAN NUM3) " +
                    "OR NUM3 LESS THAN 78 " +
                    "AND NUM34 IS ALPHABETIC-UPPER " +
                    "AND NUM92 IS ALPHABETIC-LOWER " +
                    "AND NUM0987 IS ALPHABETIC-LOWER) .";
        String result =
          new Rewriter("(NUM\\d+) +IS +(ALPHABETIC(?:-(?:UPPER|LOWER))?)")
            public String replacement()
              String type = group(2);
              if (type.endsWith("UPPER"))
                return "Character.isUpper(" + group(1) + ")";
              else if (type.endsWith("LOWER"))
                return "Character.isLower(" + group(1) + ")";
              else
                return "Character.isLetter(" + group(1) + ")";
          }.rewrite(s);
        System.out.println(result);
    }

  • Help on regular expression

    hi all
    i need to validate telephone number , and i tried to use the following expression :
    "[\\d][\\d][\\d]-[\\d][\\d][\\d][\\d]" or
    "[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]" they did not seem to work. can anyone provide some help on this? thanks in advance.

    Hi,
    Can anyone provide me the regular expression for the following?
    1. String Should contain 7 letters (can include '*') followed by 5 alphanumeric characters i.e.5 numbers/letters
    For this one, I've written reg expn = ([a-zA-Z]*[*]*[a-zA-Z]*){7}\\w{5}
    But, somehow this is not working...can anyone pleaseeeee explain wots wrong with this one or give me alternate solution???????
    2. String should contain 7 numbers or 7 digits consisting of 1 letter & 6 numbers in varying order, no spaces.
    For this one, reg expn = (\\d{7})|((\\d*[a-zA-Z]\\d*){7})
    But this is also not working...... Please help!!!!!
    3. String should contain 9 numbers or 8 alphanumeric characters i.e. 8 numbers/letters or 13 numbers
    This one looks really simple, but still (\\d{9})|(\\w{8})|(\\d{13}) is not working.....Please helpppp
    I'll appreciate if any Regular Expresion expert can resolve my problem!!! Also, I'm using gnu-regexp-1.0.8.jar as we r not using JDK 1.4!!!! We've to use only this library, no other choice...so, please suggest!!!!!!

  • Help with Regular Expression for field validation

    I'm fairly new to using regular expressions and using Acrobat. This is probably a simple question, but I've been unable to figure it out.
    I have a text field on a PDF that I would like to be 9 characters in length. The first 2 characters can only be alphanumeric, the last 7 characters can only be numeric.
    At first I was using the following, which allows all the characters to be alphanumeric:
    var re = /^[A-Za-z0-9 :\\_]$/;
    if (event.change.length >0) {
    if (event.willCommit == false) {
        if (!re.test(event.change)) {
            event.rc = false
    That works fine, but it's not quite what I needed. With some assistance I changed it (see below) to fit what I was looking for. However, this didn't work; it prevents anything from being entered in the field:
    var re = /^[A-Za-z0-9]{2}\d{7}$/;
    if (event.change.length >0) {
    if (event.willCommit == false) {
        if (!re.test(event.change)) {
            event.rc = false
    Any help would be greatly appreciated.
    Thanks...

    Here's a function you can call form the field's custom Format script. It should be placed in a document-level JavaScript:
    function custom_ks1() {
        // Define non-commited regular expression
        var re = /^[A-Za-z0-9]{0,2}([0-9]{0,7})?$/;
        // Get all of the characters the user has entered
        var value = AFMergeChange(event);
        // Allow field to be cleared
        if(!value) return;
        if (event.willCommit) {
            // Define commited regular expression
            var re = /^[A-Za-z0-9]{2}[0-9]{7}$/;
            if (!re.test(value)) {  // If final value doesn't match, alert user
                app.alert("Your error message goes here.");
                // event.rc = false
        } else {  // not commited
            // Only allow characters that match the regular expression
            event.rc = re.test(value);
    Call it like this:
    // Custom Keystroke script
    custom1_ks();

  • Help with regular expression needed

    Hi,
    Perhaps someone here can help me with my regular expression I'm trying to build in my Java code.
    The regular expression that I'm looking to build consists of any non-whitespace character up until it finds one or two <>= symbols and then any character thereafter. So both these Strings would match the expression:
    City 1==London
    Age>=18
    The regular expression that I'm using is as follows:
    (\\S+)([><=]){1,2}(.+)However, group 1 always retrieves the first <>= symbol as in "City 1=". How can I make the <>= part greedy so that it retrieves both operator symbols?
    Thanks.

    Make the first group, the non-spaces, reluctant:
    "(\\S+?)([<>=]{1,2})(.+)"

  • 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>

  • Help With Regular Expression In Apex Validation

    Apex 3.2
    There is a validation type of regular expression in apex, but I have never used regular expression before,
    so a little help is appreciated.
    I need to validate a field. It is only allowed to contain alpha characers, numbers, spaces and the - (dash) character.
    I have tried several times to get this working
    eg
    [[:alpha:]]*[[:digit:]]*[[:space:]]*[-]*
    ^[[:alpha:][:digit:][:space:]-]+?
    and others, but just can't to get the syntax correct.
    Can someone help me with this please
    Gus

    Example:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'This is some example text' as txt from dual union all
      2             select 'And this is the 2nd one with numbers' from dual union all
      3             select 'And this allows double-barrelled words with hyphens' from dual union all
      4             select 'But this one shouldn''t be allowed!' from dual
      5            )
      6  --
      7  select *
      8  from t
      9* where regexp_like(txt, '^[[:alnum:] -]*$')
    SQL> /
    TXT
    This is some example text
    And this is the 2nd one with numbers
    And this allows double-barrelled words with hyphens

  • Regular Expression Help

    I need help writting a regular expression that will match the following strings:
    1+1,1+(1+1),((1+1)+(1+1)),1+(1+(1+1)). Basically one that will match an arithmetic expression (operands limited to 1's and operators to '+' sign) with or without correctly matched parentheses. Have'nt had much luck so far. Any input will help. thanks

    okay, you asked for it:
    [1+()]+
    it will only match those string but it will tell you nothing about syntactically correct expressions. This is because these types of expression are not "regular" and cannot be properly parsed using regular expressions.

Maybe you are looking for

  • Old Quark files are now Unix Executable Files

    I made hundreds of archive CD's with Mac's running OS 9 back in 1990's. They contain Quark files and .tif's. I've referred back to these CD's many many times over the years with no problems. My new iMac has the intel processor. I pop an archive CD in

  • Data Mapping from HPM to HSF

    This is my problem. we have an application in HPM version 9.3 and a replication of it in version 11.2. These days all work done in 9.3 application is being migrated to 11.2 application. But the problem in mapping the data to HSF. When I try to map th

  • Dynamic Region: what am I doing wrong?

    Jdev. 11.1.2.3.0 I have been having problems with dynamic regions. I have two adf forms; mainPage.jsf and mainRegion.jsf. I have also two adf forms (page fragments), employee.jsff and department.jsff, I have also two bounded task flows; employee-task

  • AJAX / future development questions

    Even though AJAX is as much Web (html, xhtml, dhtml), JS, and XML as it is Java 2EE, I figured this main forum was the best place to ask a few questions (we should have a future tech discussion area. (I didn't see one but sometimes I can't seem to fi

  • HT3625 Macbook pro 13 2012 not showing line in audio when connected to preamp

    I have a preamp connected to the audio in/out jack on my macbook pro 13" 2012. when i plug the audio in from my preamp the sound only shows it as a headphone output and does not list it under input. i also have no button "use audio for:"