java - Pattern.compile null Syntax Exception -


the pattern line keeps throwing null-pointers , have no idea why. tried pattern.quote, comes as:

pattern p: \q.*(bread){1, 1}.{1, 1}(bread){1, 1}.*\e|java.util.regex.matcher[pattern=\q.*(bread){1, 1}.{1, 1}(bread){1, 1}.*\e region=0,13 lastmatch=] 

and totally not should be. want return string between 2 bread substrings.

public string getsandwich(string str) {   pattern p = pattern.compile(".*(bread){1, 1}(.{1, 1})(bread){1, 1}.*");   matcher m = p.matcher(str);    if (m.find()) {       return m.group(2);   } else {   return "";   } } 

any ideas?

you have syntax error in pattern:

.*(bread){1, 1}(.{1, 1})(bread){1, 1}.* no space ---^ here -^ , here ---^ 

btw, what's point of having quantifier expressed {1,1}?

test here: http://fiddle.re/y2mxd6


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -