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

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

membalas semua (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\.(.*)\);

      Muat turun terkini
      Lagi>
      kesan web
      Kod sumber laman web
      Bahan laman web
      Templat hujung hadapan
      Tentang kita Penafian Sitemap
      Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!