java - 下面的正则表达式应该怎么写??在线等。。。。拜托各位大神啦
大家讲道理
大家讲道理 2017-04-17 15:55:24
0
2
397
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

Antworte allen (2)
洪涛
package com.company; import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegExpDemo { public static void main(String[] args) { String[] data = { "interInfo.middNode(buff,\"卡号\",trade.text_借记卡号.getText());\n", "interInfo.middNode(buff,\"1234566790019\",trade.text_1234567890.getText());\n", "interInfo.middNode(buff,\"abcdefg\",trade.text_hijklmn.getText());\n", }; Pattern patternCardNumber = Pattern.compile("\"(\\w+)\"", Pattern.UNICODE_CHARACTER_CLASS); Pattern patternDebitCardNumber = Pattern.compile("trade.text_(\\w+).getText\\(\\)", Pattern.UNICODE_CHARACTER_CLASS); Matcher matcherCardNumber = null; Matcher matcherDebitCardNumber = null; for (String str: data) { matcherCardNumber = patternCardNumber.matcher(str); while (matcherCardNumber.find()) { System.out.println(matcherCardNumber.group(0)); System.out.println(matcherCardNumber.group(1)); } matcherDebitCardNumber = patternDebitCardNumber.matcher(str); while (matcherDebitCardNumber.find()) { System.out.println(matcherDebitCardNumber.group(0)); System.out.println(matcherDebitCardNumber.group(1)); } System.out.println(); } } }

output:

"卡号" 卡号 trade.text_借记卡号.getText() 借记卡号 "1234566790019" 1234566790019 trade.text_1234567890.getText() 1234567890 "abcdefg" abcdefg trade.text_hijklmn.getText() hijklmn
    迷茫

    ."(.)",trade\.(.*)\);

      Neueste Downloads
      Mehr>
      Web-Effekte
      Quellcode der Website
      Website-Materialien
      Frontend-Vorlage
      Über uns Haftungsausschluss Sitemap
      Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!