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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看