Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
60 lines (55 sloc) 1.76 KB
^\s*(\d+)((?: \d+)*)(\D+)[(]0?\1[)]$
matches any stage line
------------------------------------------
e.g.
Result 6
1. 6
2. 150 150 150 130 90
3. PLATT LN
Match region 1: Stage Number
Match region 2: All Fare Data space separated
Match region 3: Stage Name
------------------------------------------
^
start of line
\s*
zero or more whitespace characters
(\d+)
an integer
((?: \d+)*)
multiple integers, each with a leading space
?: indicates: Don't try to capture the inner region. The inner region is an
integer with it's leading space. Trying to capture this will only actually
capture the final integer with leading space.
Q - Does anyone know how to capture each of these integers individually?
(\D+)
one or more non-numeric-digits
[(]0?\1[)]
repeat the 1st match inside literal parentheses with an optional leading zero
$
end of line
TODO-IM-match the header notes on the Service data - of the first 4 non-captured lines, only the first 3 are of interest
TODO-IM-is it possible to grab each Fare individually? Else we can just explode the string in code.
------------------------------------------
(^[\d]{1,2})[ ]*([\d]{1,3})[ ]([\d ]*)([\w ]*)[(](\d{1,2})[)]
-----------------------------------------------------------
On:
-----------------------------------------------------------
10 190 190 190 190 150 150 150 130 90 OLD BROADWAY (10)
-----------------------------------------------------------
Gives:
-----------------------------------------------------------
10
190
190 190 190 150 150 150 130 90
OLD BROADWAY
10
-----------------------------------------------------------
^[ ]*([\d]{1,2})[ ]*([\d]{1,3})[ ]([\d ]*)([\w ]*)[(](\d{1,2})[)]
3 110 90 RNCM (03)
3
110
90
RNCM
03
-----------------------------------------------------------