0

To start with - I am new to writing regular expressions.

I have two dropdowns as FromCity and ToCity which ate HTML options (as dropdowns). However both are having same left right boundary due to which not able to extract the specific values of a drop down at runtime.

e.g.

FROM CITY DROPDOWN

<select name="fromPort" class="form-inline">
            <option value="Paris">Paris</option>
            <option value="Philadelphia">Philadelphia</option>
            <option value="Boston">Boston</option>
            <option value="Portland">Portland</option>
            <option value="San Diego">San Diego</option>
            <option value="Mexico City">Mexico City</option>
            <option value="São Paolo">São Paolo</option>
        </select>

TO CITY DROPDOWN

 <select name="toPort" class="form-inline">
            <option value="Buenos Aires">Buenos Aires</option>
            <option value="Rome">Rome</option>
            <option value="London">London</option>
            <option value="Berlin">Berlin</option>
            <option value="New York">New York</option>
            <option value="Dublin">Dublin</option>
            <option value="Cairo">Cairo</option>
        </select>

I can fetch the city names with - <option value="(.*?)"> but not able to distinguish which value is for which dropdown.

Is there a better way to handle this using regular expression ?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
singhabhisek
  • 57
  • 1
  • 8

1 Answers1

0

Using regular expressions for parsing HTML is not the best option, I would rather suggest using CSS Selector Extractor instead

This way you will be able to get "from" city names as select[name=fromPort] option and "to" city names as select[name=toPort] option

Demo:

enter image description here

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133