You should definitely see your doctor about this, to check it is not an infection (e.g. H-pylori, some form of parasite etc.). A stool test may be necessary (done this myself). Unfortunately, though, many conventional doctors lack sufficient specialised knowledge of IBS causes and are often inclined to simply prescribe 'something to reduce stomach pain'.
A comprehensive stool analysis, if you do it privately with a consultant, will set you back about £400 but may save you that much and more in the longrun because of identifying what is going on in your bowel. You can run a cheaper version which tells you less but does deal with parasite and H-pylori etc. - this is about half the price of the comprehensive test.
IBS can cover an array of different symptoms and causes but the first 2 things I recommend you do, in the immediate moment, is:
1) get hold of some VSL#3 probiotic (costs about £50 a month).
2) also start taking one capsule of a powerful enzyme supplement with each meal - this will help break down carbohydrates and other food molecules so they are more absorbable for your body and less available as food for unhealthy bacteria in the bowel. I particularly recommend Enzymedica's 'Digest GOLD' as it operates well over a broad range of pH (and is generally one of the best on the market).
The above 2 interventions will not cure you but they will help greatly in HEALTHILY alleviating some of your symptoms. Note that you will need to continue with both of these for many months, on an ongoing basis (but you will come to thoroughly appreciate how beneficial they are and will not want to be without them) Whilst you are using these 2 items to keep your symptoms somewhat in check, you can set about figuring out what exactly is causing your symptoms and deal with this underlying cause.
Also look into obtaining some Glutamine and some decent codliver oil (Blue Ice brand is best)
You should most definitely NOT make yourself eat baked beans, brown bread, weetabix, brown rice, bananas etc. until you have ascertained if you have food sensitivities - wheat, yeast and complex carbs like beans can actually exacerbate IBS (source: personal experience/suffering). Your stated pattern of constipation alternating with diarrhea is absolutely classic of food sensitivity. For more on possible 'danger' foods, see:
http://tinyurl.com/kk9jl
It is important to point out that what foods one IBS sufferer may have trouble with may not necessarily be the same as those another person struggles with, so the above website should NOT be considered a holy grail, just a useful starting point.
Not specifically IBS-focused, but nonetheless relevant in your case, is the LATTER PART of my answer in an old post about dietary fibre (the section about grains and bran from "P.S." downward - the earlier recommendations in that post are not all suitable for people with IBS, so please overlook those) :
http://tinyurl.com/32kbk8d
Back specifically to IBS, a good healthy source of dietary fibre which will NOT exacerbate IBS in most cases is simply consuming plenty of dark leafy green vegetables such as broccoli, cabbage, etc. (cabbage, in particular, contains glutamine in significant quantities, which is very healing to gastric mucosa). Do NOT eat grains (e.g. wheat, barley, oats etc.) unless you absolutely have to. Do make sure you consume foods rich in vitamin A and D, such as codliver oil and/or pasture-fed GHEE (butter that has had the lactose removed - Pukka do an organic ghee, available in health food stores) as these are very helpful in healing the epithelial layers of the digestive system.
OK, so far, I've suggested you moderate your symptoms with a powerful probiotic and eliminate many foods which can cause a flare-up in symptoms (you will notice your diet becomes very limited for a while, but don't panic - there is a way forward, which I'll explain). You will need to learn to be extremely conscious of how your diet affects your symptoms - keeping a food diary can be a chore, but TRUST ME it is worth its weight in gold - you will far more quickly learn which foods worsen your symptoms if you keep one. If you want testing, there are many labs in the USA who'll do it for you, but it can, of course, get expensive:
http://tinyurl.com/323jjm9
http://tinyurl.com/2vpboxg
http://tinyurl.com/35rqmbf
Personally, I could not afford food allergen testing (I did get the comprehensive stool testing done, though, that I mentioned at the beginning of my answer). As far as foods go, I found I was sensitive to virtually ANY food that was acidic - this includes tomatoes, vinegar, berry fruits, citrus, kiwi etc. Beans, lentils, pulses, grains, lactose etc. all problematic, too. Note that many beans, pulses and grains are high in phytic acid which causes many digestive issues even for those without IBS. They can also contain lectins, too, which are a potential problem in themselves.
Alcohol is also wise to avoid if you have IBS. It is damaging to the gastrointestinal tract.
SO, why is it that you have begun to develop food sensitivities?
Well, again, there are a number of possibilities but here are a few to consider:
Something, initially unbeknown to you, begins to send your digestive system off-balance. This change can lead to an altering of PH in the gut. Alternatively (or additionally), it can lead to a reduction in how well foods are broken down at various points in the digestive system (for example, H-pylori could increase pH in the gut, meaning proteins don't get broken down properly, or, with no H-pylori in the equation, you could, perhaps have developed soft, painless gallstones which impede bile flow from the gallbladder and thus disrupt signaling to the pancreas, so enzyme release does not occur correctly, again meaning foods do not get broken down properly. Larger food particles thus make their way down to the bowel and the immune system can misinterpret these as foreign invaders. If this happens, the immune system can initiate inflammation of the lining of the bowel, and, if allowed to continue for many weeks and months, the long-term inflammation can lead to severe damage of the gut lining which allows yet more undigested particles to cause havoc with the immune system as they begin to be able to freely enter the bloodstream.
To complicate matters, even if you are not 'infected' with a pathogen like H-pylori, various bacteria, which already commonly exist in the human bowel, can nonetheless overrun your bowel, leading to pain and inflammation as they feed on certain of the aforementioned 'danger' foods and excrete inflammation-causing toxic byproducts. How do they overrun the bowel? Well, if something alters the pH of the bowel then it can become more favourable for unhealthy bacteria (and sometimes parasites, too) to proliferate than for the healthy bacteria to. This is why I suggest that, as an initial plan of attack, you get yourself on a powerful probiotic.
IBS really is a complex topic and it's taken me a long time to learn what I know, finding each piece of information the hard way. I simply don't have sufficient space to explain everything in detail for you here.
I wrote more on the topic a while back, wherein I posted some other information links:
http://tinyurl.com/35wbask
1) get yourself on a *POWERFUL* probiotic (e.g. VSL#3 or Ohirra's or Metagenics or BioCare Replete). Some people find fermented foods helpful, others find they make symptoms worse (I've found BOTH to be true for me, at different stages). If you're not sure, then avoid fermented foods for now and just go with a commercial probiotic as I've described
2) you very very probably have bacterial imbalance/dysbiosis in your bowel, so you'll need to be very careful which foods you eat. A food diary is extremely helpful. Dr. David Dahlman explains this thoroughly in his eBook (linked in my other post)
3) You need to find out WHY you have bacterial imbalance in the first place - is it due to an infection by a pathogen (bacterial, protozoan, or parasitic etc.) OR is it due to something like obstructed bile flow due to undiagnosed gallstones? (read Andreas Moritz' book http://tinyurl.com/3xt3vfs - WELL worth reading)
£200 + may seem like a lot of money for a stool test but, as I said, it can turn out to be money well spent. See links in my linked answer.
4) IBS is CURABLE. I'll say it again: IBS is *CURABLE* - you do not need to suffer with it, or mask its symptoms for the rest of your life. Many doctors assume it is incurable because they do not understand the systemic processes which can underlie it and therefore never solve the causal factors. It may take you some time to figure out what the underlying cause is for you. Personally, it took me about 5 years to finally figure out that mine was due to liver congestion, on account of undiagnosed gallstones - the alteration of pH was leading to insufficient pancreatic enzyme production and thus caused immune response lower down in the bowel AND bacterial dysbiosis in the bowel, the two frequently going hand-in-hand, as I've described. I had not realised I had gallstones because a) I had no gallbladder pain and b) I had done gallbladder flushes but nothing ever came out - I erroneously thought I was in the clear, but I was just too congested to expel them.
Good luck to you and I hope I've given you a few shortcuts which will save you from suffering for as long as I have.
Take care.