zoukankan      html  css  js  c++  java
  • 正则

    (http|ftp|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)+\.(png|jpg|gif|gif)

    (http|ftp|https)://(\\S+?)\\.(jpg|png|gif)

    string s = "http://link1.jpg bha http://link2.png blahblah http://link3.gif";
    foreach (Match m in Regex.Matches(s, "http://(\\S+?)\\.(jpg|png|gif)"))
    {
        Console.WriteLine(m.Groups[1].Value);
    }

    private static Regex RegTel = new Regex(@"^([0-9a-zA-Z]|[\u4e00-\u9fa5]|\[|\]|\(|\)|,)+$");

     .replace(/"type":".*?"/,'type:""')

    aa=aa.replaceAll("\"ccfsID\":\"[0-9]*\"", "\"ccfsID\":\""+id1+"\"");

    Regex regCountry = new Regex("(?:Country_Code\":\")([^\"]+)(?:\")", RegexOptions.IgnoreCase);
    if (regCountry.Match(GameInfo).Success) {
    var regResult = regCountry.Match(GameInfo).Groups[1].Value;
    if (!string.IsNullOrEmpty(regResult)) {
    result = regResult;
    }
    }

     (?:Country_Code\\":\\")([^\\]+)(?:\\")

    (?:exp) 匹配exp,不捕获匹配的文本

     (?:Country_Code\\":\\")([^\\]+)(?:\\")

    Regex regCountry = new Regex("(?:Country_Code\":\")([^\]+)(?:\")", RegexOptions.IgnoreCase);

    //java

    (?:\\"playerName\\":\\")([^\\]+)(?:")

    System.out.println(gameInfo+"\n"+gameInfo.length()+"\n");
    if (gameInfo.contains("\\\"playerName\\\":\\\","))
    {
    System.out.println("replace");
    gameInfo=gameInfo.replace("\\\"playerName\\\":\\\",","\\\"playerName\\\":\\\"\\\",");
    }
    else
    {
    String regexPlayName="(?:\\\\\"playerName\\\\\":\\\\\")([^\\\\]+)(?:\")";
    Matcher matcherPlayName=Pattern.compile(regexPlayName).matcher(gameInfo);

    if (matcherPlayName.find())
    {
    String oldPlayerName=matcherPlayName.group(0);
    System.out.println(oldPlayerName);
    String newPlayerName=oldPlayerName.substring(0,oldPlayerName.length() - 1)+"\\\"";

    System.out.println(newPlayerName);
    String ret=matcherPlayName.group(1);
    System.out.println(ret);
    gameInfo=gameInfo.replace(oldPlayerName,newPlayerName);
    }
    //while(matcher2.find())
    //{

    //}

    }
    System.out.println(gameInfo+"\n"+gameInfo.length()+"\n");

  • 相关阅读:
    UI5 Databind
    the meaning of myconputer environment path
    Linux查看日志常用命令
    fw: IP bonding in Linux.
    FW:expect tcl install
    install ET underlinux
    转expect 文一篇。
    linux 集萃
    try expect and autoexpect
    linux 压缩种类
  • 原文地址:https://www.cnblogs.com/zwei1121/p/1260938.html
Copyright © 2011-2022 走看看