Jump to content

Recommended Posts

Hiya peeps,

 

i need some help with replacement basically i have these lines,

 

Blue Cobra Piano Restaurant20 High St Theale Reading RG70118 930 4040
Spice Indian Restaurant35-37 High St Thatcham RG1901635 862 228
Alamin Tandoori takeaway75 Basingstoke Road Reading RG2 0ER0118 987 2706
Village Tandoori Restaurant & Takeaway14 Kidmore End Road Reading RG4 8SD0118 946 3939
Garden Of Gulab130-134 Wokingham Rd Reading Berkshire RG6 1JL0118 966 7979
Kathmandu Kitchen55-59 Whitley Street Reading RG2 0EG0118 986 4000
Gulshan Indian Restaurant20-24 Station Hill Reading RG1 1NF0118 958 9914
Bina Tandoori21 Prospect St Caversham Reading Berkshire RG4 8JB0118 946 2115
Standard Tandoori141-145 Caversham Rd Reading Berkshire RG1 8AU0118 950 0255
Spice Oven Restaurant2-4 Church St Caversham Reading Berkshire RG4 8AT0118 948 1000

 

and i need to replacer that will print them line this automatically,

 

Blue Cobra Piano Restaurant, 20 High St, Theale, Reading, RG7, 0118 930 4040
Spice Indian Restaurant, 35-37 High St, Thatcham, RG19, 01635 862 228
Alamin Tandoori takeaway, 75 Basingstoke Road, Reading, RG2 0ER, 0118 987 2706
Village Tandoori Restaurant & Takeaway, 14 Kidmore End Road, Reading, RG4 8SD, 0118 946 3939
Garden Of Gulab, 130-134 Wokingham Rd, Reading, Berkshire, RG6 1JL, 0118 966 7979
Kathmandu Kitchen, 55-59 Whitley Street, Reading, RG2 0EG, 0118 986 4000
Gulshan Indian Restaurant, 20-24 Station Hill, Reading, RG1 1NF, 0118 958 9914
Bina Tandoori, 21 Prospect St, Caversham, Reading, Berkshire, RG4 8JB, 0118 946 2115
Standard Tandoori, 141-145 Caversham Rd, Reading, Berkshire, RG1 8AU, 0118 950 0255
Spice Oven Restaurant, 2-4 Church St, Caversham, Reading, Berkshire, RG4 8AT, 0118 948 1000

 

how would i do this ?

 

James.

Link to comment
https://forums.phpfreaks.com/topic/166776-solved-spliiting-replacing-help/
Share on other sites

i'v made it do this so far

 

Blue Cobra Piano Restaurant20 High St, Theale, Reading, RG7,0118 930 4040
Spice Indian Restaurant35-37 High St, Thatcham, RG19,01635 862 228
Alamin Tandoori takeaway75 Basingstoke Road, Reading, RG2 0ER,0118 987 2706
Village Tandoori Restaurant & Takeaway14 Kidmore End Road, Reading, RG4 8SD,0118 946 3939
Garden Of Gulab130-134 Wokingham Rd, Reading, Berkshire, RG6 1JL,0118 966 7979
Kathmandu Kitchen55-59 Whitley Street, Reading, RG2 0EG,0118 986 4000
Gulshan Indian Restaurant20-24 Station Hill, Reading, RG1 1NF,0118 958 9914
Bina Tandoori21 Prospect St, Caversham, Reading, Berkshire, RG4 8JB,0118 946 2115
Standard Tandoori141-145 Caversham Rd, Reading, Berkshire, RG1 8AU,0118 950 0255
Spice Oven Restaurant2-4 Church St, Caversham, Reading, Berkshire, RG4 8AT,0118 948 1000

 

all i need now is the start split how would i do this ?

Blue Cobra Piano Restaurant20 High St, Theale, Reading, RG7,0118 930 4040
Spice Indian Restaurant35-37 High St, Thatcham, RG19,01635 862 228
Alamin Tandoori takeaway,75 Basingstoke Road, Reading, RG2 0ER,0118 987 2706
Village Tandoori Restaurant & Takeaway,,14 Kidmore End Road, Reading, RG4 8SD,0118 946 3939
Garden Of Gulab130-134 Wokingham Rd, Reading, Berkshire, RG6 1JL,0118 966 7979
Kathmandu Kitchen,55-59 Whitley Street, Reading, RG2 0EG,0118 986 4000
Gulshan Indian Restaurant,20-24 Station Hill, Reading, RG1 1NF,0118 958 9914
Bina Tandoori,21 Prospect St, Caversham, Reading, Berkshire, RG4 8JB,0118 946 2115
Standard Tandoori,141-145 Caversham Rd, Reading, Berkshire, RG1 8AU,0118 950 0255
Spice Oven Restaurant2-4 Church St, Caversham, Reading, Berkshire, RG4 8AT,0118 948 1000

 

iv got that far the rest is way out of my league :( any help ?

 

and i need to replacer that will print them line this automatically

 

And you are from England?! If you want help at least take the time to write a comprehendable sentence and actually explain what you want. Don't make people who are volunteering their time have to figure out what you want. You could have at least stated that you want to separate the applicable address parts with a comma and space. It was not obvious from just looking at the two lists.

 

As for your problem there are some things that you may be able to do, but nothing you create will be 100% accurate because of the variability of addresses. Your first option should be to go to the source to get better formatted data. Where are you getting this data? Are you extracting it from a file or web page? There might be a better method to preserve whatever delimiters exist.

 

Assuming there is no better method of getting the data, here are some of the rules I would start with (again this will not be 100% accurate):

 

1. Split the Name and street address based upon the first numeric character (of course if the business name has a number in it you're screwed)

2. Then working from the back get the last 13 characters (11 numbers and two spaces) as the last code

3. Again working from the back, Check the characters that are 2-3 from the end to see if they are "RG", if so take the last three as the next code. If not, check characters 6-7 from the end to see if they are "RG". If so, take the last 7 characters. If both of those fail - I don't know what you should do.

 

4. Working fro the end again, take the last 'word' as the city. I base this on the examples you gave, but I'm sure you will have cities that are two words which will break this logic.

 

5. Whatever remains is the street address

 

I would write some code for this, but because of the issues I noted above this is most likely not worthwhile endeavor

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.