Reputation: 5656
I parse one web page and need to get min and max values for slider elements. All page i parse with Jsoup, but this values i can't get this it.. they in javascript blocks.
<script>
$(function(){ $("#p_slider").slider({ range:true, step:1000, min:2000, max:49490.00, values:[2000,49490.00], slide:function(event, ui) {
$("#p_from").val((ui.values[0] != 2000)?ui.values[0]:"");
$("#p_to").val((ui.values[1] != 49490.00)?ui.values[1]:"");
$("#p_from").change();
$("#p_to").change();
} }); });
</script>
<script>
$(function() { $("#filter_543_slider").slider({ range:true, step:1000, min:0, max:17600.000, values:[0,17600.000], slide:function(event, ui) {
$("#f543_from").val((ui.values[0] != 0)?ui.values[0]:"");
$("#f543_to").val((ui.values[1] != 17600.000)?ui.values[1]:"");
$("#f543_from").change();
$("#f543_to").change();
} }); });
</script>
I need to get min and max values for #p_slider and #filter_543_slider
Now i try with this code:
String min = bodyHTML.split("[$(\"#"+searchingIdent+"\").slider({]")[1].split("[min:]")[1].split(",")[0];
String max = bodyHTML.split("[$(\"#"+searchingIdent+"\").slider({]")[1].split("[max:]")[1].split(",")[0];
But i catch error: err:length=1; index=1
And this splitting getting too much time.. +5-10 seconds
Please, tell me how to get needed substrings correct and fast.
Sorry for my english.
Upvotes: 1
Views: 189
Reputation: 47965
I would recomment to use regular expressions. I wrote this one here for you:
\$\("#([a-z0-9_]+)"\)\.slider\([^\)]+min:([0-9\.]+)[^\)]+max:([0-9\.]+)
This one checks for a jquery line which expects a id (or better the # sign) and after that a slider function where the parameters min and max are inside.
Try also this fiddler to check my result.
The first result is the id, the second one the min value and the third one is the max value.
Upvotes: 1