3 regular expression and java crash WHY?? / HOW to SOLVE IT?

Hi, i hava problem on my program there is 3 regex after another.
The JAVA crash down idona know why
want to solve it how i think i have to clear the regex so they not be in the memory after proccessing
help needed >> Please

asfdal-qsa wrote:
contents = contents.replaceAll("(?i)(<\\s*\\w*[^>]*?>((?:.*?\\s*?)+)<\\s*?/\\s*?\\w*\\s*?>)", " ");if i use replaceAll or not it is the same output
Java crash down and give me this
Exception in thread "main" java.lang.StackOverflowError
at java.util.regex.Pattern$Curly.match(Pattern.java:3746)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
at java.util.regex.Pattern$Loop.match(Pattern.java:4295)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
at java.util.regex.Pattern$Curly.match1(Pattern.java:3797)
at java.util.regex.Pattern$Curly.match(Pattern.java:3746)
at java.util.regex.Pattern$Curly.match1(Pattern.java:3797)
at java.util.regex.Pattern$Curly.match(Pattern.java:3746)
and still continue
Edited by: asfdal-qsa on Apr 12, 2009 7:14 AMWhat's wrong with my suggestion:
"<[^<>]++>"?

Similar Messages

  • Rhino, Regular Expression and Java \r\n

    Hi guys,
    I have an application that allow the user to create some regex to compare values by using scripting, basically I am using the test code
            ScriptEngineManager mgr = new ScriptEngineManager();
            ScriptEngine engine = mgr.getEngineByName("rhino");
            String[] scripts = {"/[abc]+/.test(\"giscaaard\")",
                                      "/[abc]+/.test(\"giscaaard\r\")"};                           
            for(String script : scripts){
                Object result = engine.eval(script);
                System.out.println(script + ":" + result);
            }//end forSo I run a simple test
    The output is
    /[abc]+/.test("giscaaard"):true
    Exception in thread "main" javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: unterminated string literal (<Unknown source>#1) in <Unknown source> at line number 1
    at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
    at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:124)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
    at threads.Threads.main(Threads.java:34)
    Java Result: 1
    Any idea why rhino doesn't accept \r\n? If there is a standard for this where I can get how it handles other characters?
    PS: In fact my first idea was to use only java classes for perform such things, however when I try to importClass(java.lang.String) I get an exception saying rhino already has one. Is there anyway on how I can give up rhino default classes and use the java one?
    Thanks and Regards

    Hi guys,
    I just figure out something else
    The code:
    ScriptEngineManager mgr = new ScriptEngineManager();
            ScriptEngine engine = mgr.getEngineByName("rhino");
            String[] scripts = {/*"\"giscard\" == \"giscard\"",
                                "\"giscard\" == \"giscard\"",
                                "\"gff\" < \"giscard\"",
                                "\"gff\" > \"giscard\"",
                                "5 == 1",
                                "27 > 9",*/
                                "'Giscard'\n'SecondLine'",
                                "\"Giscard\tFaria\"",
                                "'Giscard\tFaria'",
                                "'Giscard\nFaria'"
            for(String script : scripts){
                Object result = engine.eval(script);
                System.out.println(script + ":" + result);
            }//end forGives the output
    'Giscard'
    'SecondLine':SecondLine
    "Giscard Faria":Giscard Faria
    'Giscard Faria':Giscard Faria
    Exception in thread "main" javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: unterminated string literal (<Unknown source>#1) in <Unknown source> at line number 1
    at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
    at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:124)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
    at threads.Threads.main(Threads.java:36)
    Java Result: 1
    So, the \r\n has nothing to do with regex, it seems that javascript doesn't support string variables that has the \r \n inside it, however other special characters like \t are supported. Any idea on how to handle that?
    Regards

  • Regular Expressions and java

    hi everybody i have a little question:
    Does anybody have an idea how i can accomplish the following task:
    I want to have a regex that excludes words that contain a ++, --, __ but any word contains single occurence of these characters (+,-,_) should be matched.
    I tried anything that i could think of but i can't seem to be able to find a working regex. Anybody have an idea

    It took me a while to get my head around possessive
    quantifiers and atomic groups, and what they're good
    for. They can be a little tricky--Friedl
    himself got burned by them in the third edition of
    MRE, as shown in the errata for pages 481-2:
    http://regex.info/errata3.html
    It's good to see that even those living on Mt. Olympus can get it wrong sometimes.
    My version of Friedl is a correction on the first edition and is dated Nov 1997. In my version, 'possessive quantifiers' are proposed as a possible solution to a problem but Friedl does not mention any implementations. It may be time to fork out some cash and buy the latest version.

  • Juniper MX Regular expressions and user permissions ACS 5.4

    Hi everyone!
    Im having some trouble with regular expressions and permissions on our Juniper MX routers through ACS 5.4, and i would like some insight/help/poitners!!
    We have a team of engineers that should only have read only permissions (important: show configuration) and also be able to just change the description on interfaces.
    Thus far with the following regular expressions set for the shell profile they are going through i have managed the above, however the problem is when an engineer inputs "Show configuration", only the interfaces descriptions configuration is shown! The rest of the configuration will not be printed.
    deny-commands1=.*.
    allow-commands1=configure
    deny-configuration1=.*.
    allow-commands2=interfaces .*. description .*$
    allow-configuration1=interfaces .*. description .*$
    allow-commands2=show configuration.*
    allow-commands3=show configuration
    (some of these regex i know that are not needed, i was just playing around to check everything before posting)
    Any pointers as to why or how to resolve this?
    example output with the above:
    show configuration
    ## Last commit: 2014-01-09 09:34:44 EET by someone
    interfaces {
        xe-0/0/0 {
        xe-0/0/1 {
            description xxxx;
        xe-0/1/0 {
            description xxxx;
        xe-0/1/1 {
            description xxxx;
        xe-0/2/0 {
            disable;
        xe-0/2/1 {
            description xxxx;
        xe-0/3/0 {
            description xxxx;
        xe-0/3/1 {
            description xxxx;
        ae0 {
            description "xxxx";
        ae1 {
            description xxxx;
        demux0 {
        lo0 {
    {master}
    Thanks in advance!
    Spyros

    You are absolutely right!!  I was doing research online after posting the above.  The correct RADIUS attribute to use is actually CVPN3000/ASA/PIX7.x-Group-Based-Address-Pools.  Then create the pool in ASA, and call that pool's name in ACS under that RADIUS attribute.  Someone explained this perfectly in this community before.  Much appreciate your answer!
    Here's from another post last year:
    ACS  5 does not have the feature of IP pools. Logically its always good to  setup pools locally on vpn server and if you want user to pick ip from  specific local pool you can configure acs to push that attribute.
    On ACS Go to > Policy Elements  -> Network Access ->   Authorization Profiles -> Create ->
    Name of the Policy ->Dictionary Type: Radius-Cisco VPN 3000/ASA/PIX7.x
    Attribute Type : CVPN3000/ASA/PIX7.x-Group-Based-Address-Pools
    Attribute Type: String
    Attribute Value : Static MYPOOL (Name of the Pool which is defined on the ASA)
    Access Policies ->Default Network Access -> Authorization ->  Create -> Under result section call the Authorization p

  • Regular expression and line break problem

    Hi friends,
    I was trying out one regular expression in java but, for some reasons its not working. The test string looks something like this in the eclipse watch window:-
    Test string:-*
    Content-Disposition: form-data; name="name"\n\nOmkar\n|
    In the above test string the last character is a pipe symbol.
    And the java code i have written is: -
    code:
        public static void getParameterValue(String paramName, String testParameter) {
                  String parameterRegex = "name=\""+paramName+"\"(.*)|";
                  Pattern pattern = Pattern.compile(parameterRegex,Pattern.DOTALL);
                  Matcher matcher = pattern.matcher(testParameter);
                  boolean isFound = matcher.find();
                  if (isFound) {
                       System.out.println("The parameter value is : "+matcher.group(1));
             }After, the debug line moves over the first line in this method, the value contained in the "parameterRegex" string variable is:-
    Regex:-*
    name="name"(.*)|
    However, my SOP statement, prints null....even though, "isFound" variable is true....can someone please explain me what could be the problem, where i am going wrong ?....
    I have even, set the DOTALL option for the regex.
    please some one help me!
    Thanks and Regards
    Omkar Patkar

    zomkar wrote:
    Sorry, folks, i did not mention the fact that i had posted the my query, in Java ranch also. But my problem lead to another problem of CROSS - POSTING !
    Apologies, for that !....but please, does any one have a solution to my regex ? .... any one ? please ?
    The value i get in paramaname is :- name
    which is present in double quotes in test string.
    is my regex incorrect ?The discussion at JavaRanch seems to be pretty alive, so why not leave this thread and continue there? That way, people won't have to first read two different threads on two different forums before trying to help you.

  • Java parser for regular expression to java program

    Hi All,
    I am very new to parser technologies .I am looking for a (java)parser which can read the "regular expression" and can convert it into "java program".Please let me know is there any thing related to this.
    Thanks in advance.
    Your will be appriciate.
    Regards,
    Sai.

    Hi Jos,
    Thank you for your quick response .You're welcome.
    If you have any sample code or simple example for how to use those
    classes (Pattern,Match) ,will you please send me .It will be helpful for me.Jverd gave you two nice links already in his reply #3
    If there is any "open source" for parsering regular expressions.
    Please send me I am very new to parser technologies.Note that that Pattern class take care of all the parsing of REs, i.e. there's
    nothing 'interesting' left for you to do any parsing whatsoever. Can you
    elaborate a bit on what you exactly want to do and learn?
    kind regards,
    Jos

  • Regular expressions and sql

    I have working regular expressions and a working sql connection, but I don�t know how to stop the info from getting into the database when input doesent match the regular expression.
    For instans, you put in an e-mail without an "@" and my program writes and error message. But the info still gets in to the database.
    Any help would be much apreciated as I dont know where to start. If you have links or code examples that would be great to.
    Thanx.

    Well, the obvious answer is "only write the data to the database if the input doesn't match the regular expression."
    Presumably you're really asking how to do that - but it depends upon how your application is structured in the first place, and you haven't told us anything at all about that.

  • Using regular expressions in java

    Does anyone of you know a good source or a tutorial for using regular expressions in java.
    I just want to look at some examples....
    Thanks

    thanks a lot... i have one more query
    Boundary matchers
    ^      The beginning of a line
    $      The end of a line
    \b      A word boundary
    \B      A non-word boundary
    \A      The beginning of the input
    \G      The end of the previous match
    \Z      The end of the input but for the final terminator, if any
    \z      The end of the input
    if i want to use the $ for comparing with string(text) then how can i use it.
    Eg if it is $120 i got a hit
    but if its other than that if should not hit.

  • Regular expressions and backreference

    Hello!
    I am trying to use backreferences in REGEXP in the PERL-style, where I want to match my regular expression and later refer to the grouped values. I can read that those are referecenced with \1 .. \9, but I simply cant get it to work. Here is an example in PL/SQL:
    SELECT REGEXP_SUBSTR(l_users.adresse,'([A-Z]+)\s+(\d+)')
    INTO l_dummy_varchar2
    FROM dual;
    OR I could do things like:
    l_dummy_varchar2 := REGEXP_SUBSTR(l_users.adresse,'([A-Z]+)\s+(\d+)');
    It seems to work, but I cant figure out how to get the backreferenced value.
    I would love to do things like:
    dbms_output.put_line('my value ='||\1)
    but this doesnt work.
    Help is very much appreciated.
    Best regards
    Dannie

    Likewise you can extract things using the
    REGEXP_SUBSTR, but you don't need back
    referencing...backreferencing is better than additional function (ltrim) use, and BTW be careful with this "ltrims":
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2       v_txt VARCHAR2(100);
      3     BEGIN
      4       v_txt := ltrim(regexp_substr('HERE IS AN ASCII CHARACTER', 'IS AN [[:alnum:]]*'),'IS AN ');
      5       DBMS_OUTPUT.PUT_LINE('Word after IS AN: '||v_txt);
      6  END;
      7  /
    Word after IS AN: CII
    PL/SQL procedure successfully completed
    SQL>
    SQL> DECLARE
      2       v_txt VARCHAR2(100);
      3     BEGIN
      4       v_txt := regexp_replace('HERE IS AN ASCII CHARACTER', 'IS AN ([[:alnum:]]*)|.','\1');
      5       DBMS_OUTPUT.PUT_LINE('Word after IS AN: '||v_txt);
      6  END;
      7  /
    Word after IS AN: ASCII
    PL/SQL procedure successfully completed
    SQL> -----------
    VB
    http://volder-notes.blogspot.com/

  • Regular expression in java -- specifically email

    Does anyone know how I can do a regular expression with java that is going to retrieve an email address pattern.
    For example, let's say i have a huge string
    this is a sample test. perhaps someoen can tell me how to retrieve my [email protected] from this string. sincerely yours [email protected]
    could someone explain to me how to retrieve these emai addresses most efficiently using java's regular expressions
    thanks
    stev

    A citing (http://jregex.sourceforge.net/examples-email.html):
    String someValidChars="[\\w.\\-]+";
    String someAlphaNums="\\w+";
    String dot="\\.";
    Pattern email=new Pattern(someValidChars + "@" + someValidChars + dot + someAlphaNums);

  • Regular Expressions with Java Regex

    Hi,
    I'm playing around with regex and there's something I can't get to work. What I need, is to capture words between 2 other words and the words captured has to be higher than 5 characters, so for example:
    Pattern "Just testing on something with regular expressions" and suppose I'll try to match all the words between "testing" and "regular", then only the word "something" should come out because "on" and "with" are not larger than 5 chars.
    Now I'm quite new to regexps and I know that ((?<=\btesting\b).*(?=\bregular\b)) will return " on something with "
    But I can't seem to come up with an expression that would only output the word "something". I've tried a few expressions like ((?<=\btesting\b)((?:[\s\w{1,3}])*(\b\w{4,}\b)*(?:[\s\w{1,3}])*)*(?=\bregular\b)) which also returns " on something with " The others I tried would either return the whole " on something with " or return "Not Found!"
    Does anyone have a tip for me? I'm well aware that it's not too hard to do something like this in Java, but I'm really looking to study regular expressions and would like to accomplish this using a regular expression.
    The Java program I use is the following:
    C:\Program Files\Java\jdk1.5.0_16\bin>java RegexTest "((?<=\btesting\b).*(?=\bregular\b))" "Just testing on something with regular expressions"
    public class RegexTest {
         public static void main(String[] args) {
              Pattern RegexCompile = Pattern.compile(args[0]);
              Matcher m = RegexCompile.matcher(args[1]);
              boolean found = m.find(); // Perhaps there's another function to find () that would do the job?
              if (found)
              System.out.println(m.group()); // Perhaps group() is not the right function for this case?
              else
              System.out.println("Not Found!");
    Edited by: dli2k3 on Sep 19, 2008 11:32 AM
    Edited by: dli2k3 on Sep 19, 2008 11:33 AM

    You're talking about a two-stage operation: find everything between those two words, then filter out anything that's less than five letters long. There's no single regex that will accomplish all that in one step.
    By the way, please use &#x7B;code} tags when you post source code.

  • Can somebody help me in getting some good material for Regular Expressions and IP Community list

    can somebody help me in getting some good material for Regular Expressions and IP Community list

    I'm not sure what you mean by "IP Community list", but here are 3 reference sites for Regular Expressions:
    Regular Expression Tutorial - Learn How to Use Regular Expressions
    http://www.regular-expressions.info/tutorial.html
    Regular Expressions Cheat Sheet by DaveChild
    http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
    Regular Expressions Quick Reference
    http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm

  • Regular expression and XML

    Hello,
    I have an XML file containing regular expressions and i parse the file, extract the pattern from it and search for it using java regex package. The problem is it works fine when patterns are words but when the pattern is something like
    write \\d+ (write followed by a space followed by one or mre digits) it doesn't work.
    I wrote the same code but with the pattern embedded in it,ie. without using XML and it worked. But when extracting with XML it fails.
    Also if the pattern is write[0-9] it only extracts write[0-9 and gives an error of no closing bracket.
    Could anyone please tell me what i am missing out
    Thank you

    thank you for your replies. Well i have still no got over the problem so i am posting my code here and hoping it can get solved
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import java.io.*;
    import java.util.regex.*;
    class textextractor extends DefaultHandler{
         boolean regex=false;
    public void startElement(String namespaceURI,String localName,String qn,Attributes attr)
              if(localName.equals("REGEX"))
               regex=true;
    public void characters(char [] text,int start,int length)throws SAXException {
              String t=new String(text,start,length);
              boolean flag=false;
              if(regex==true)
                Pattern pattern;
                  String w=new String(t);
              pattern = Pattern.compile(w);
              Matcher matcher;
              matcher=pattern.matcher("there is a bat   read  write 13    error at line ");
              while(matcher.find())
               flag=true;
               System.out.println("I found the text \"" + matcher.group() +"\" starting at index "
               + matcher.start() +"and ending at index " + matcher.end() + ".");
             if(!flag)
               System.out.println("not found");
             regex=false;
    public class saxt2 {
         public static void main(String args[]) {
              try {
                    XMLReader parser= XMLReaderFactory.createXMLReader();
                    ContentHandler handler=new textextractor();
                    parser.setContentHandler(handler);
                                    parser.parse("d:\\regex.xml");
                  }catch (Exception e) {
                   System.err.println(e);
    }The xml file is
                      <RegularExpression>
                      <REGEX>write</REGEX>
                      <REGEX>write \\d+</REGEX>
                      <REGEX>read[0-9]</REGEX>
                      </RegularExpression>by running the code you can see that write is found,write \\d+ doesn't match write 13 in the string and read[0-9] gives and error.
    Any help will be greatly appreciated

  • Regular expression and output format

    hi all,
    i have following scenario-
    regular expression: [0-9]{3}-[0-9]{3}-[0-9]{4}
    generated value by the above regular expression: 123-234-6789
    output format to display the generated above value: xxx-xxx-$1
    now i need to display the generated value (123-234-6789) in the specified output format (xxx-xxx-$1) and the final output will be xxx-xxx-6789
    how is it possible?
    Note: here regular expression and output format can vary
    br,
    bashar

    Hi, Bashar
    You can solve this problem by using the Data Masking Technique.
    Masking data means replacing certain fields with a Mask character (such as an X). This effectively disguises the data content while preserving the same formatting on front end screens and reports. For example, a column of credit card numbers might look like:
    4346 6454 0020 5379
    4493 9238 7315 5787
    4297 8296 7496 8724
    and after the masking operation the information would appear as:
    4346 XXXX XXXX 5379
    4493 XXXX XXXX 5787
    4297 XXXX XXXX 8724
    The masking characters effectively remove much of the sensitive content from the record while still preserving the look and feel. Take care to ensure that enough of the data is masked to preserve security.
    It would not be hard to regenerate the original credit card number from a masking operation such as: 4297 8296 7496 87XX since the numbers are generated with a specific and well known checksum algorithm.
    Best Regards,
    Mahfuz Khan

  • Assistance with Regular Expression and Tcl

    Assistance with Regular Expression and Tcl
    Hello Everyone,
      I recently began learning Tcl to develop scripts for automating network switch deployments. 
    In my script, I want to name the device with a location and the last three octets of the base mac address.
    I can get the Base MAC address by : 
    show version | include Base
     Base ethernet MAC Address       : 00:00:00:DB:CE:00
    And I can get the last three octets of the MAC address using the following regular expression. 
    ([0-9a-f]{2}[:-]){2}([0-9a-f]{2}$)
    But I have not been able to figure out how to call the regular expression in the tcl script.
    I have checked several resources but have not been able to figure it out.  Suggestions?
    Ultimately, I want to set the last three octets to a variable (something like below) and then call the variable when I name the switch.
    set mac [exec "sh version | i Base"] (include the regular expression)
    ios_config "hostname location$mac"
    Thanks for any assistance in advance.
    Chris

    This worked for me.
    Switch_1(tcl)#set result [exec show ver | inc Base]   
    Base ethernet MAC Address       : 00:1B:D4:F8:B1:80
    Switch_1(tcl)#regexp {([0-9A-F:]{8}\r)} $result -> mac
    1
    Switch_1(tcl)#puts $mac                               
    F8:B1:80
    Switch_1(tcl)#ios_config "hostname location$mac"      
    %Warning! Hostname should contain at least one alphabet or '-' or '_' character
    locationF8:B1:80(tcl)#

Maybe you are looking for

  • Adobe Acrobat 9 Pro making .log files instead of .pdf files

    I just uninstalled Acrobat 9 from one computer and installed it on my new one.  Now when I try to create a .pdf, it's creating a .log file instead. I have tried uninstalling again and installng it. Also, there is NOT a pdf hiding somewhere else. The

  • Re-using toplink code for database adapter

    Hi, I have a project in which multiple BPEL processes will be implemented. Some of them use database adapters to connect to various staging areas. Is it possible to setup JDeveloper in such a way that I can create the toplink side for the database ad

  • FLEX to send SWIFT messages to banks

    Anyone here used FLEX to send SWIFT messages to banks? is this a bad idea?

  • Why is airport scanning so much?

    Every couple of minutes airport's status will switch from "on" to "scanning". It will stay scanning for about three seconds and then go back to "on". Why does it find the need to scan for wireless networks when I'm already connected to my wireless ro

  • HREAP with web-auth (internal)

    I have a lwap at a remote site that is configured as HREAP so that it can continuously provide connectivity when the WLC is un-reachable.  I have two vlans on the lwap.  One is locally authenticated and locally switched for intranet connectivity.  Th