Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

replaceAll not found ???

Moderators: kris

Posted: 03/13/08 02:52:04

Using tango 0.99.5 (and dmd 1.027 that came with it), I am getting a very strange error.

$ make gtp.d(36): import replaceAll not found gtp.d(36): alias gtp.replaceAll recursive alias declaration make: *** [housebot-0.7] Error 1

$ grep -n replaceAll gtp.d 36:import tango.text.Regex : replaceAll, split; 462: char[] squeezedLine = replaceAll(replaceAll(replaceAll(replaceAll(line, "\t"," ")," "," ")," ","")," $","");

The code compiled in 0.99.4. I changed sub(x,y,"g") to replaceAll(x,y) and updated the import. I'm completely baffled by the error. Any ideas?

Author Message

Posted: 03/13/08 02:55:18

I should add that I'm confident I'm using 0.99.5 libraries. They are the only tango files on the system. I was also inspired to make the code changes due to compiler errors when upgrading to 0.99.5 and trying to recompile the code.

Posted: 03/13/08 09:44:04

As far as I know, the Regex API changed with 0.99.5, so you might want to adjust your code a bit.

Posted: 03/13/08 19:59:35

The process of "adjusting my code a bit" for the new 0.99.5 API is how I hit this problem. For this specific issue, the sub function was removed (as best I can tell). Since I was doing greedy substitution, I opted for replaceAll. The odd thing is that the compiler can't find replaceAll even though I see it plain as day in the 0.99.5 source. I'm currently stumped by this since it should simply work.

Posted: 03/13/08 21:00:41

try

Regex(pattern).replaceAll(Regex(pattern2).replaceAll(input, replacement2), replacement)

or you can use a wrapper like this:

string replaceAll(string input, string pattern, string replacement, string optional_buffer=null) {

return Regex(pattern).replaceAll(input, replacement, optional_buffer);

}

Posted: 03/13/08 21:34:54

Thanks jascha... I didn't even notice the functions were part of the Regex class :( Maybe I should learn my lesson and not program tired...