import re
p = re.compile(r"([\d\W]+)\n.*\[(.*)\].*\n.*", re.MULTILINE | re.UNICODE)
test_str = u"""00:00:05,233 --> 00:00:08,133
GAT[xd]fES: Amelia Earhart
is on one of the final legs
00:00:05,333 --> 00:00:08,433
[xd]fES: Amelia Earhart
is on one of the final legs
"""
subst = r"\1 \2"
result = re.sub(p, subst, test_str)
print result
ideone.com/K0zp7X 1812
01:22:07,367 --> 01:22:09,300
[Police radio chatter]
В итоге хочу получить запись вида:
Police radio chatter 01:22:07,367 01:22:09,300
import re
s = """1812
01:22:07,367 --> 01:22:09,300
[Police radio chatter]"""
time = re.findall(r"\d{2}:\d{2}:\d{2}", s) # ['01:22:07', '01:22:09']
text = re.findall(r"[^\d\[\]:,\s\->]+", s) # ['Police', 'radio', 'chatter']
var api_host = '';
$(function() {
function get_search_results(query_id) {
$.ajax({
data: '', // id search result
url: api_host+'/api/result',
type: 'GET',
success: function(response) {
console.log(response);
console.log("Everything finished, no errors");
},
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status == 401) {
console.log("Error 401");
}
if (jqXHR.status == 404) {
console.log("Not finished");
}
}
});
};
$('.sendButton').click(function() {
$.ajax({
url: api_host+'/api/search',
data: $('form').serialize(),
type: 'POST',
success: function(response) {
get_search_results(response); // или response['id'], зависит от формата ответа
},
error: function(error) {
console.log(error);
}
});
});
});