Java Regex Engine Crashing -


regex pattern - ([^=](\\s*[\\w-.]*)*$)

test string - paginationinput.entriesperpage=5

java regex engine crashing / taking ages (> 2mins) finding match. not case following test inputs:

paginationinput=5  paginationinput.entries=5 

my requirement hold of string on right-hand side of = , replace something. above pattern doing fine except input mentioned above.

i want understand why error , how can optimize regex requirement avoid other peculiar cases.

you can use behind make sure string starts @ character after =:

(?<=\\=)([\\s\\w\\-.]*)$ 

as why crashing, it's second * around group. i'm not sure why need that, since sounds asking :

  • a single character, equals
  • then 0 or more repeats of following group:
    • any amount of white space
    • then amount of word characters, dash, or dot
  • end of string

anyway, take out *, , doesn't spin forever anymore, i'd still go more specific regex using behind.

also, don't know how using this, why did have $ in there? can match last 1 in string (if have more one). seems you'd better off look-ahead new line or end: (?=\\n|$)

[edit]: update per comment below.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -