0


I have write some regexp for this but i don't get exact one.
please check this link.
In this i want differentiate Location field into three parts.

Ref Link: https://avayacorp.authoria.net/joblist.html

  1. country
  2. State
  3. City

Please give more suggestions in this.

Girish
  • 136
  • 1
  • 12
  • What is the regex you have written? Can you show it? That will make it easier for us to point out what can be improved about it. – O. R. Mapper Nov 21 '13 at 10:19
  • Looking at the list on the website, I am not sure you will anywhere with only regex. Probably, you will have to split the string and then figure out by looking at the separate parts which is which. The list is truly not very tidy, many lines have different formats. For example, some do not explicitly list a country, some do not indicate a city, ... and mind you, in many countries, the state is irrelevant for addresses and never usually listed along with a city name, which is why that website often shows the 2-letter-country code right after the country. – O. R. Mapper Nov 21 '13 at 10:22
  • I Writed this for the getting city in this [\w]{2}-([\w]*)$ and State ([^-]*)-[^-]*$ – Girish Nov 21 '13 at 10:58
  • Do you run the regex against the html code ? What is your flavor ? – Stephan Nov 21 '13 at 23:03

2 Answers2

1

I assume that you try to differentiate location field right from html code.

Try this regex

">([^-/]+)-([^-]+)-([^-/]+)<

Description

Regular expression visualization

Demo

here

Stephan
  • 41,764
  • 65
  • 238
  • 329
0

Consider the following Regex...

(?<=-?)\w+(?=-?)

Good Luck!

gpmurthy
  • 2,397
  • 19
  • 21