I would strongly suggest that you go back to your doctors and ask about movicol. Lactulose is what used to be used before movicol was invented, and for 99% of kids movicol works much better and is what is nationally recommended.
Treating a toddler who has been constipated for so long does take patience...but patience on the right treatment. The first question is whether or not he has a backlog (hard poo that can be felt in his tummy - I presume someone has checked for this?...also suggestive if he ever swings between hard poo and diarrhoea) If he does have a backlog, then that needs clearing out before much progress can be made. If he doesn't have a backlog, progress can be quicker.
Sciency bit: the last bit of the gut is like a stretchy squeezy hosepipe, which sits empty waiting for poo to come along. In someone who is not constipated, a wave of pushing brings poo down into the last bit of the gut, which gives you the sensation of "oops, need to find the toilet before long". If you're constipated, then poo stays sitting in that stretchy hosepipe. It might start because someone hasn't drunk as much so the poo is harder, or it might have hurt to poo last time so they don't want to, or they might just have poo'd out a bit, and not all of it. But some poo is left in there. And the longer it is in there, the more water is sucked out of it, making it harder, and drier, and more difficult to pass. In the meantime more poo is coming down for higher up, but again, not all the poo in the bottom end of the gut is pushed out, so more and more builds up. All of it getting harder and drier. This hard rocky poo starts stretching out the walls of the stretchy squeezy hosepipe. So now you have a big baggy area of gut, which because of that isn't as good at pushing (or at knowing when there's a natural wave of pushing, which might help the poo come out), filling up more and more with poo that's harder and harder to push out. Sometimes things get so blocked up in there, with the gut trying to push through stuff that won't move, that squidgy poo from much higher up leaks past, looking like diarrhoea. The hard poo can also hurt to come out, leading the poor kid to start trying not to poo. Oh, and the bumhole can start to get stretched by all the weight of the poo higher up, so sometimes they start leaking little bits of poo.
Now, if you or me ended up that constipated, we'd be pretty much stuck that way. Kids, thankfully, are as good at healing up on the inside as on the outside. But the gut can only "unstretch" and heal up, if nothing's stretching it up any more. So if there are loads and loads of hard rocks in there, those need shifting. Even if there aren't loads of hard rocks, the poo needs softening, and keeping soft for long enough for the gut to heal up (usually months).
Treatment: at this age, the main treatment for almost all kids is movicol. This is a powder that can be mixed into any non-boiling liquid. The idea is that the powder hangs onto the liquid and takes it down into the gut, softening up the poo. In low doses, it just softens things up. In big doses it can helpfully dissolve away the old rocks of hard poo. Lactulose is a softener too, but only really works to soften things up a bit - great for slightly constipated small babies, or someone who has only just become a bit constipated. But really not much good for a child with longstanding constipation. The other problem with lactulose is that because noone is expected to use high doses any more, because if they need a high dose everyone expects them to be on movicol, the dose book that GPs have to follow only gives pretty small doses. I remember doing constipation clinics before movicol was invented...30 ml 3 times a day was pretty common in small toddlers...and still didn't really do the job. Suppositories/enemas - can occasionally be useful if they're in a lot of pain right now but they only really shift the very lowest bit of poo, and not the rocks higher up, and quite a lot of the experts worry that they make the small child focus even more on their sore bum.
The clear out: if they need a clear out (which it is pretty much impossible to say over the internet, - sorry) then this is done by giving steadily increasing amounts of movicol over about a week, until you have at least 3 days of enormous emounts of gravy-like poo. That seems to be about the point at which almost all of them will have cleared out all the rocks.
After the clear out/if they don't need a clear out: the poo needs to be kept much softer than "normal" to let everything heal up. This tends to translate to as much movicol as it takes to achieve "daily pain-free passage of soft poo - approximately the consistency of scrambled egg". how much movicol that takes...anywhere between 1/2 to 4 sachets per day. And it's really important to keep that poo soft for months, to get everything nicely healed up, then only reduce the movicol very gradually.
Food/diet: it is, of course, really important to encourage lots of fluids, and fruit and veg. But that won't work on it's own...it's more about if you can persuade him to do really well with those, he's more likely to successfully come off the movicol sooner.
Underlying causes: Cows milk protein intolerance is pretty effective at giving them constipation. You mentioned the constipation came from when he was weaned. Had you been advised to wean dairy free, or was that when he started having dairy again? If that was when he started having dairy again it might be worth trying a couple of weeks dairy free - nut milks and oat milks seem to be the favourite subsitute at this age - but it might make no difference. And if it did help, and you decided to stay dairy free, you'd need to see a paediatric dietician to make sure about calcium intake etc. The other (unlikely) thing that can be a cause in children who start with constipation when they're weaned is coeliac disease (full on wheat intolerance) - it's unlikely, but might be worth asking if it's been ruled out. Hirschsprung's - even more unlikely, but not saying impossible. Usually the kids with Hirschsprung's are constipated from the very start (not from when they are weaned). The big warning sign tends to be if they're still constipated despite full constipation treatment. So that would be had a clear out, and on a decent dose of movicol every day, and still not pooing....and in particular if struggling to pass soft poo. So it might be worth testing, but as it involves an anaesthetic/camera test, probably well worth checking the response to a decent level of treatment first.
Hope that helps/gives you some ideas about what to ask.
A "useless" doctor 