good day.. i would like to ask if you guys know how to match street no. in regex?
because im helping a friend in his project about regular expression...
good day.. i would like to ask if you guys know how to match street no. in regex?
because im helping a friend in his project about regular expression...
For that you need to grep some pattern. How the value is coming in string?
you have to findout some common pattern of street number..
for example
Example 1 : Racecourse Road, Street 1/A, USA
Example 2 : St.Thomas Road - 2B, USA
Example 3 : 4, Parssippany Road, Near xyz hotel
So here are too many different pattern of Street number..
First do you have same pattern of string for street number?
or you have different different patterns?
If it is same then it's easy to made function otherwise need to apply some logic.
hmmm...
- this project will accept international street name
- i only want the number with the attached letter in a street..
- for example "123-A INGLES ST."
- so i would match 123-A
- but the street number(which is 123-A) can be put anywhere in the street(123-A INGLES ST) ex. "INGLES ST. 123 - A", "INGLES 123 A ST."
-so can you please provide a logic that will match the street number anywhere it is placed in the street
thanks for replying quickly..
hmmm...
- this project will accept international street name
- i only want the number with the attached letter in a street..
- for example "123-A INGLES ST."
- so i would match 123-A
- but the street number(which is 123-A) can be put anywhere in the street(123-A INGLES ST) ex. "INGLES ST. 123 - A", "INGLES 123 A ST."
-so can you please provide a logic that will match the street number anywhere it is placed in the street
Check below example.. It will handle almost all of your case..
Try out
<?php
$str1 = 'INGLES ST. 123 - A'; // CASE 1 //
$str2 = 'INGLES ST. 123 A'; // CASE 2 //
$str3 = 'INGLES ST. 123-A'; // CASE 3 //
$str4 = 'INGLES ST. 123A'; // CASE 4 //
$str5 = 'INGLES ST. 123'; // CASE 5 //