0
複数の行にまたがるテキストとのマッチングの際にPythonの正規表現が動作するのに少し問題があります。私の例は次のとおりです:複数行のJavaScriptコードにマッチする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 =\[\[(.+?)\]\]"
をしかし、それは仕事をdoesntの結果として、私は次のようになりたいです。
この正規表現を試すことができますが、あなたは 're.MULTILINE'または' re.DOTALL'を試してみましたか? –
おそらく正規表現で間違っています。 – user3568005