Why doesn't this Java regex compile? -


i trying extract pass number strings of of following formats:

passid_132 passid_64 pass_298 pass_16 

for this, constructed following regex:

pass[i]?[d]?_([\d]{2,3}) 

-and tested in eclipse's search dialog. worked fine.

however, when use in code, doesn't match anything. here's code snippet:

string idstring = filename.replaceall("pass[i]?[d]?_([\\d]{2,3})", "$1"); int result = integer.parseint(idstring); 

i tried

java.util.regex.pattern.compile("pass[i]?[d]?_([\\d]{2,3})") 

in expressions window while debugging, says "", whereas

java.util.regex.pattern.compile("pass[i]?[d]?_([0-9]{2,3})") 

compiled, didn't match anything. problem?

there's nothing invalid tegex, sucks. don't need character classes around single character terms. try this:

"pass(?:id)?_(\\d{2,3})" 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -