Text Cleaning Problem: help desperately sought

I am a complete novice to scripting and for that matter grep so I am throwing myself at the mercy of this bulletin board.
My problem seems, or should I say seems to me, to fall into the category of easy-if you know how.
My problem is I don’t know how and am looking for help.

I will try to describe my problem as clearly as I can.

I am in the process of trying to tidy up some text, a hell of a lot of it or I would do it manually, but before I can get anywhere with the routine stuff (stripping multiple spaces and feeds etc) I have an obstacle to overcome.
The text I have to clean is destined for database fields and before I can go anywhere with it I need each record to only occupy one line and one line only. At present it is spread over two lines, The first line is the address and the second is a phone number. On the plus side at least the problem is a pretty consistent one, on the downside until I resolve it I can’t even get started.

To illustrate I will provide a tiny sample from one of the many text files I have to clean exactly as it looks now, complete with extra spaces etc (they are not the problem though):

Beechness Nursing Home Rathvensdale Leighlintown
(057) 9733366
Morris Lawns Nursing Home Morris Co Carlow
(058) 9963112
Hillview Convalescence & Nursing Home Boyle rd, Meath
(059) 8239507
Moyvale Nursing Home Ballon
(067) 5859299
St Patrick’s Lakeside Home Mucross
(021) 6151986

Many of the files that require work differ in obvious ways to this one but the one consistent element which, I think, would enable a script or grep pattern to work perfectly on all of them is the fact that the start of the second line will always contain a short series of numbers (not always limited to 3, some will be 2 and some will be more than 3) in brackets. What I need to do is to tell a text editor something like this: "find all lines starting with a bracket set (is that the right term?) containing numbers, precede them with a back space and insert a tab. The Tab insertion is actually very important as without it I will have another problem to replace my old one.

I have, no doubt used more words to describe this problem than is needed, if you took the trouble to read to the end, thanks. If you can help me at all, even more thanks.

Thanks

P.S. I only really posted this here out of desperation. My head is spinning from grep tutorials and the more I try to get anywhere the further away I get. I am not a coder or scripter but I know enought to realise that I need help from this area.

No idea about grep myself, but I would use something as this for the task you exposed:

set oldText to "Beechness Nursing Home Rathvensdale Leighlintown
(057) 9733366
Morris Lawns Nursing Home Morris Co Carlow
(058) 9963112
Hillview Convalescence & Nursing Home Boyle rd, Meath
(059) 8239507
Moyvale Nursing Home Ballon
(067) 5859299
St Patrick's Lakeside Home Mucross
(021) 6151986"

set newText to ""

repeat with i in paragraphs of oldText
	try
		if character 1 of i is not "(" or character 5 of i is not ")" then error --> check for (000)
		word 1 of i as number
		set newText to (text 1 thru -2 of newText) & tab & i & return
	on error --> paragraph does not match
		set newText to newText & i & return
	end try
end repeat

newText -->
(*
"Beechness Nursing Home Rathvensdale Leighlintown	(057) 9733366
Morris Lawns Nursing Home Morris Co Carlow	(058) 9963112
Hillview Convalescence & Nursing Home Boyle rd, Meath	(059) 8239507
Moyvale Nursing Home Ballon	(067) 5859299
St Patrick's Lakeside Home Mucross	(021) 6151986
"
*)

jj, Thanks very much for taking the trouble of setting that up for me. I greatly appreciate your help and if it works I can scarcely describe the amount of heartache you will have saved me.

If it does not work, as envisaged (perish the thought), I hope you won’t mind my posting details of the behavior exhibited as I would then be still desperately seeking salvation.

Once again, thank you very much for your help.

Regards

BD

One of the hazards of trying to help the complete novice is that they are liable to mess up at a very fundamental level and I suspect that is why I cannot get your script to execute.

Here is the exact code i used and saved in application support-bbedit-scripts:

set oldText to “Beechness Nursing Home Rathvensdale Leighlintown
(057) 9733366
Morris Lawns Nursing Home Morris Co Carlow
(058) 9963112
Hillview Convalescence & Nursing Home Boyle rd, Meath
(059) 8239507
Moyvale Nursing Home Ballon
(067) 5859299
St Patrick’s Lakeside Home Mucross
(021) 6151986”

set newText to “”

repeat with i in paragraphs of oldText
try
if character 1 of i is not “(” or character 5 of i is not “)” then error → check for (000)
word 1 of i as number
set newText to (text 1 thru -2 of newText) & tab & i & return
on error → paragraph does not match
set newText to newText & i & return
end try
end repeat

No doubt my level of ignorance is now completely exposed.