Java Pattern Stack Overflow Error
Contents |
here for a quick overview of the site Help Center Detailed
Java Regex Stackoverflowerror
answers to any questions you might have Meta Discuss the java regex stack overflow workings and policies of this site About Us Learn more about Stack Overflow the java default stack size company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Jvm Xss
the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up StackOverflowError when matching large input using RegEx up vote 2 down vote favorite 1 I got StackOverflowError when matching the result
Java Increase Stack Size
using a RegEx pattern. The pattern is (\d\*?(;(?=\d))?)+. This regex is used to validate the input: 12345;4342;234*;123*;344324 The input is a string consists of values (only digits) separated by ;. Each value could include one * at the end (used as wildcard for other matching). There is no ; at the end of the string. The problem is that this regex works fine which small number of values. But when the numbers of values is too large (over 300), it will cause StackOverflowError. final String TEST_REGEX = "(\\d\\*?(;(?=\\d))?)+"; // Generate string StringBuilder builder = new StringBuilder(); int number = 123456; for (int count = 1; count <= 300; count++) { builder.append(Integer.toString(number).concat(";")); number++; } builder.deleteCharAt(builder.lastIndexOf(";")) builder.toString().matches(TEST_REGEX); //<---------- StackOverflowError And the stacktrace: java.lang.StackOverflowError at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556) at java.util.regex.Pattern$Loop.match(Pattern.java:4683) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615) at java.util.regex.Pattern$Ques.match(Pattern.java:4079) at java.util.regex.Pattern$Ques.match(Pattern.java:4079) at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556) at java.util.regex.Pattern$Loop.match(Pattern.java:4683) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615) at java.util.regex.Pattern$Ques.match(Pattern.java:4079) at java.util.regex.Pattern$Que
here for a quick overview of the site Help Center Detailed answers to any questions you regex online might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community http://stackoverflow.com/questions/15082010/stackoverflowerror-when-matching-large-input-using-regex of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up StackOverflowError when matching large input using RegEx up vote 2 down vote favorite 1 I got StackOverflowError when matching the result using a RegEx pattern. The pattern is (\d\*?(;(?=\d))?)+. This regex is used to validate http://stackoverflow.com/questions/15082010/stackoverflowerror-when-matching-large-input-using-regex the input: 12345;4342;234*;123*;344324 The input is a string consists of values (only digits) separated by ;. Each value could include one * at the end (used as wildcard for other matching). There is no ; at the end of the string. The problem is that this regex works fine which small number of values. But when the numbers of values is too large (over 300), it will cause StackOverflowError. final String TEST_REGEX = "(\\d\\*?(;(?=\\d))?)+"; // Generate string StringBuilder builder = new StringBuilder(); int number = 123456; for (int count = 1; count <= 300; count++) { builder.append(Integer.toString(number).concat(";")); number++; } builder.deleteCharAt(builder.lastIndexOf(";")) builder.toString().matches(TEST_REGEX); //<---------- StackOverflowError And the stacktrace: java.lang.StackOverflowError at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556) at java.util.regex.Pattern$Loop.match(Pattern.java:4683) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615) at java.util.regex.Pattern$Ques.match(Pattern.java:4079) at java.util.regex.Pattern$Ques.match(Pattern.java:4079) at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556) at java.util.regex.Pattern$Loop.match(Pattern.java:4683) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615) at java.util.regex.Pattern$Ques.match(Pattern.java:4079) at java.util.regex.Pattern$Ques.match(Pattern.java:4079) at java.util.regex.Pattern$BmpCharProperty.match(Pattern.java:3715) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4556) at java.util.regex.Pattern$Loop.match(Pattern.java:4683) at java.util.regex.Pattern$GroupTail.match(Pattern.java:4615) ... I think the lookahead in the pattern cause this error since there are lots of lookup but I haven't fig
here for a quick overview of the site Help Center Detailed answers to any questions you http://stackoverflow.com/questions/7662613/pattern-matches-gives-stackoverflowerror might have Meta Discuss the workings and policies of this site https://coderanch.com/t/449271/java/java/java-regular-expression-giving-stack About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of stack overflow 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Pattern.matches() gives StackOverflowError up vote 18 down vote favorite 4 I'm using java's Pattern.matches to match a block of data to a regex. The block of data can be a single line or multiple lines. The java regex stack problem is that once my data becomes more than 15 lines (typically more than 17-18 lines), i start getting stackoverflowerror. For data less than 15 lines the regex works fine. The Regex is of this format: domainname -> space -> , -> space -> number -> space -> , -> space -> number -> newline String regex = "^(([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+([a-zA-Z]{2,})\\s*,\\s*\\d+\\s*,\\s*\\d+(\\r?\\n)?)+$"; The data block i use to test against this regex is this abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 abc.com, 123, 456 This is the code: String regex = "^(([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+([a-zA-Z]{2,})\\s*,\\s*\\d+\\s*,\\s*\\d+(\\r?\\n)?)+$"; boolean valid = Pattern.matches(regex, data); //fails here java regex stack-overflow share|improve this question edited Oct 5 '11 at 14:47 asked Oct 5 '11 at 14:08 Purav Shah
Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums Forum: Java in General java regular expression giving stack overflow ? steve labar Ranch Hand Posts: 55 posted 7 years ago I'm having a very difficult time trying to get this regular expression in java to work. I just don't understand why it is not working. It appears to work in a perl script.The idea is to check if this target is landing in html and is breaking out of a double quote in an html tag. example: injecting this in a http request: "xss="xss()" would be true would be false single ticks started tag Regex: used to match <\w('(\\'|[^'])*'|"(\\"|[^"])*"|[^'">])*xss="xss\(\)" I know it must be using recursion and just keeps looking.but regex appears to be good? please help! Error: Exception in thread "Thread-35" java.lang.StackOverflowError at java.lang.Character.codePointAt(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) at java.util.regex.Pattern$Loop.match(Unknown Source) 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) at java.util.regex.Pattern$Loop.match(Unknown Source) 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) Rob Spoor Sheriff Posts: 20703 68 I like... posted 7 years ago Steve, next time you get a StackOverflowError, can you please shorten it? After a while it is looping, and there is no reason to show all of that. I cut off part of your stack trace; the relevant part is still there. SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6 How To Ask Questions How To Answer Questions steve labar Ranch Hand Posts: 55 posted 7 years ago yeah, sorry about that. Henry Wong author Marshal Posts: 21675 85 I like... posted 7 years ago For something like this, it may be a good idea to provide a sample program that demostrates the error... The way you describe this, we have no i