JOEL-T99 2021-07-14 22:32 采纳率: 100%
浏览 71
已采纳

正则表达式如何找到匹配的第n次

data.*?],

能匹配到三次结果,但后面加{2}也取不到第二次的内容,求援助

<script type="text/javascript">
    "use strict";
    //折线图
    var myChart = echarts.init(document.getElementById('dealCharts'));
        var option_0 = {
        title: {},
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'line',
                lineStyle: {
                    color: '#000'
                },
                z: 1
            },
            backgroundColor:'rgb(255,255,255)',
            extraCssText:'box-shadow:0 0 3px 3px rgba(0, 0, 0, 0.3)',
            textStyle:{
                color:'#333'
            },
            formatter: function (target) {
                if(target[1].data==0){
                    return '';
                }
                var date=new Date(target[0].axisValue * 1000);
                var text='';
                text+=date.getFullYear()+'年'+ (date.getMonth()+1) +"月";

                if(target[0].seriesName){
                    text+='</br>';
                    text+=target[0].marker;
                    text+=target[0].seriesName;
                    text+=':'+target[0].data+'元/㎡';
                }

                if(target[1].seriesName){
                    text+='</br>';
                    text+='<span style="display:inline-block;margin-right:5px;width:9px;height:9px;background-color:rgb(253,201,21);"></span>';
                    text+=target[1].seriesName;
                    text+=':'+target[1].data+'套';
                }

                return text;
            }
        },
        grid: {
            left: '0',
            right: '0',
            bottom: '0',
            containLabel: true
        },
        legend: {
            x: 'left',
            show: true,
            selectedMode:false,  //取消图例上的点击事件
            data: ['成交均价', '成交量']
        },
        xAxis: {
            data: ["1593532800","1596211200","1598889600","1601481600","1604160000","1606752000","1609430400","1612108800","1614528000","1617206400","1619798400","1622476800"],
            axisLabel: {
                interval: 0,
                formatter: function (value) {
                    var date = new Date(value * 1000);
                    return (date.getMonth()+1) + '月';
                }
            },
            axisLine: {
                lineStyle: {
                    color: '#999'
                }
            }
        },
        yAxis: [
            {
                type: 'value',
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#999'
                    }
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    //show:false
                },
                min: 0,
                max:50000,
                interval: 10000            },
            {
                type: 'value',
                axisLine: {
                    show: true,
                    lineStyle: {
                        color: '#999'
                    }
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    show: true,
                    lineStyle: {
                        color: '#dadada'
                    }
                },
                min: 0,
                max:10,
                interval: 2            }
        ],
        series: [

            {
                name: '成交均价',
                type: 'line',
                data: [33230,30434,30434,30434,30434,32982,31456,31456,35151,35580,29397,29397],
                symbol: 'circle',
                symbolSize: 6,
                itemStyle: {
                    normal: {
                        color: "rgb(246,160,9)",
                        borderColor: 'rgba(246,160,9,0.3)',
                        borderWidth: 6,                    }
                },
                lineStyle: {
                    normal: {
                        color: "rgb(246,160,9)",
                        width: 1
                    }
                }
            },
            {
                name: '成交量',
                type: 'bar',
                yAxisIndex: 1,
                data: [1,1,0,0,0,1,1,0,1,1,2,0],
                barWidth: 18,                itemStyle: {
                    normal: {color: 'rgb(253,201,21)'}
                }
            }
        ]
    };

  • 写回答

3条回答 默认 最新

  • 忍气吞声埋头苦干 2021-07-15 12:17
    关注

    re.findall(r"name: '成交均价',\n.+\n(.+)",data)[0].strip()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 已采纳回答 7月15日
  • 创建了问题 7月14日

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探