Skip to content
Advertisement

how to “regex” all options in select menu

The sample data is this:

JavaScript

With the following code I can capture only one data:

JavaScript

How can I capture all data to “SIZExSIZE” (e.g 50×80 or 150×230) and “Stock: [0-9]” until the last Select.

Advertisement

Answer

Just change (.*) by ([sS]*?)</select>

so the complete regexp would be: <select name="ctl00$ContentPlaceHolder1$UrunListesi$ctrl([0-9]{1,2})$StokBoyut" id="ctl00_ContentPlaceHolder1_UrunListesi_ctrl([0-9]{1,2})_StokBoyut">([sS]*?)</select>

Demo

. does not match new lines so you may use [sS] instead which matches anything.

Once you have the select you want. Use an extra regex value=".*?_(d+(?:xd+)?)">.*?Stok:(d+) for getting the size and stock values (first and second capturing group)

For example:

JavaScript

See it in action here.

Result

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement