0

I am struggling with the following text:

c(\Study:\", \"Job:\", \"Branch:\", \"Position:\", \"Naming:\", NA, NA, \"Banker\", \"VP of Sales\", \"\", NA, NA, NA, NA, NA)"

I would like to get from a regex, the VP of Sales. Instead of the VP of Sales other things can be exactly at this place.

I tried the following, \\\"(.*?)\" which captures all the text around, but not the VP of Sales.

Any suggestions? I appreciate your reply!

Carol.Kar
  • 4,581
  • 36
  • 131
  • 264
  • Is what you want always in the nth column? Is it the only column that contains spaces or contains "of?" What do other rows of data look like? Be more specific. Otherwise, I'll simply recommend `\\\"(VP of Sales)\"` – Wes Foster Feb 06 '17 at 19:55
  • Your input is incorrect. You have missed one `"` between `Study` in the beginning of the text. Correct regex should be `\\\"(.*?)\\\"` – Uladzimir Palekh Feb 06 '17 at 19:57
  • @WesFoster Instead of the `VP of Sales` other things can be exactly at this place. I want the 7th column basically. Any suggestions? – Carol.Kar Feb 06 '17 at 20:00
  • @UladzimirPalekh No there is no `"` missing. That`s exactly my problem. The data looks like this... – Carol.Kar Feb 06 '17 at 20:01

1 Answers1

2

Since the data you want will always be in the same column, just do this:

/(?:, [^,]+){7}, \\\"(.*?)\\\".*/g

Basically, this skips the first 7 columns (delimited by , [^,]) (number can be changed in {7}) and captures the data in quotes that comes immediately after it, then ignores the rest.

Here's a demo: http://www.regexpal.com/?fam=96828

Wes Foster
  • 8,770
  • 5
  • 42
  • 62