Mike,

Answer to Q1: the \s will match spaces, tabs, and LINE BREAKS. You
have  "rd" followed by a "line break" followed by a "6". That is why
your match is going across 2 lines.

Answer to Q2: no clue what you mean by getting the result twice.

Try this regex:

\b(?:(?:rural delivery)|(?:rd))(?: |\t)*\d

Should give you the following:

Rural delivery 1
RD2
RD 3
rural Delivery 3
rd  1
rUrAl DeLiVeRy 2

On May 5, 5:19 pm, Mike Adams <[email protected]> wrote:
> Using this tool:http://www.spaweditor.com/scripts/regex/index.php
>
> Using this regex:
> /(\s[r|rural]+\s?[d|delivery]+\s*\d)/i
>
> Using this sample data set:
> "
> 2 West coast, Rural delivery 1
> 20 West Coast Road, RD2
> 222 Hard Road, RD 3, Tiparere
> 3 hard 11 hard
> 33 ford road rural Delivery 3
> 1 fords road rd  1
> 5 foo rd
> 6 left road rUrAl DeLiVeRy 2
> "
>
> Q1 ?
> Setting "preg_match_all" i am getting one false positive to sort out.
> That is across two lines. It is the "rd" at the end of "5 foo rd" and the 6
> starting the next line.
>
> Q2?
> Not sure why i get each result twice.
>
> TIA

-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to