c# - regular expression to extract google places result -
i writing windows phone application utilizing google places autocomplete api. results being returned follows :
northern caribbean university, mandeville, manchester parish, jamaica
spanish town, saint catherine parish, jamaica
- new harbour village,old harbour, saint catherine parish, jamaica
is there way me before parish part i.e before "manchester parish" or "saint catherine parish" using regular expression or something.
algorithm
- split string array. split on
,
- loop through array. return items until find entry containing parish, stop processing or split array here. ( item containing parish matches
^.*[pp]arish.*$
) - convert have string again if desired
-- or --
if want capture portion before parish item , done use positive lookahead this:
.*(?=,[^,]*[pp]arish)
fiddle
fiddle has more explicit capture group if need , examples shown
Comments
Post a Comment