在匹配跨越多行的文本时,我在使用Python正则表达式时遇到了一些问题。我的例子是:
function initialize()
{
var myLatlng = new google.maps.LatLng(23.800567,5.942068);
var myOptions =
{
panControl: true,
zoomControl: true,
scaleControl: false,
streetViewControl: true,
zoom: 11,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var bounds = new google.maps.LatLngBounds();
var locations = [
['<div CLASS="Tekst"><B>tss fsdf<\/B><BR>hopp <BR><\/div>', 54.538665,24.885818, 1, 'text']
,
['<div CLASS="Tekst"><\/div>', 24.465462,24.966919, 1, 'text']
]我想提取的是位置的上下文。因此,我想要看起来像:
- '<div CLASS="Tekst"><B>tss fsdf<\/B><BR>hopp <BR><\/div>',
54.538665,24.885818, 1, 'text'
- '<div CLASS="Tekst"><\/div>', 24.465462,24.966919, 1, 'text'我尝试如下所示的正则表达式:
regex = r"var locations =\[\[(.+?)\]\]"但是它不起作用。
发布于 2017-01-26 17:53:55
你好,你可以试试这个正则表达式
re.findall("(<div.+)\]",toparse)https://stackoverflow.com/questions/41870645
复制相似问题