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

  1. split string array. split on ,
  2. loop through array. return items until find entry containing parish, stop processing or split array here. ( item containing parish matches ^.*[pp]arish.*$ )
  3. 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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -