`
as619864232
  • 浏览: 321749 次
社区版块
存档分类
最新评论

Java Pattern 翻译

阅读更多

java.util.regex

Class Pattern

java.lang.Object
  java.util.regex.Pattern
All Implemented Interfaces:
Serializable

public final class Pattern
extends Object
implements Serializable

A compiled(编辑) representation(描述) of a regular expression(正则表达式).

A regular expression(正则表达式), specified as a string, must first be compiled(编译) into an instance of this class. The resulting(致使) pattern can then be used to create a Matcher object that can match arbitrary(任意) character sequences against(违反) the regular expression(正则表达式). All of the state involved(涉及) in performing(执行) a match(匹配) resides(存在) in the matcher, so many matchers can share the same pattern.

A typical(典型的) invocation(调用) sequence is thus

 Pattern p = Pattern.compile("a*b");
 Matcher m = p.matcher("aaaaab");
 boolean b = m.matches();

A matches method is defined by this class as a convenience(方便) for when a regular expression is used just once. This method compiles(编译) an expression and matches an input sequence against() it in a single invocation. The statement

 boolean b = Pattern.matches("a*b", "aaaaab");

is equivalent(相等的) to the three statements above, though for repeated(重复) matches it is less efficient since it does not allow the compiled(编译) pattern to be reused(再用).

Instances of this class are immutable and are safe for use by multiple concurrent threads. Instances of the Matcher class are not safe for such use. 

分享到:
评论

相关推荐

    一个java正则表达式工具类源代码.zip(内含Regexp.java文件)

    以前写了一个java的正规表达式的java工具类,分享一下,有用到的欢迎下载使用。 如果你有常用的定义好的,且测试通过的正规表达式,欢迎跟贴,也让我享用一下 . 类中用到了 jakarta-oro-2.0.jar 包,请大家自己在 ...

    《Software Architecture Design Patterns in Java》原版PDF 下载

    《Software Architecture Design Patterns in Java》PDF 下载,本来是想0分的,但最低只能设置2分。

    外文翻译 stus MVC

    This article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help you control change in your Web project and promote ...

    java8源码-jcohy-study-sample:个人学习整理

    翻译文档: PS:待开发中。。。。 我的学习笔记,记录学习过程中的笔记以及遇到的问题,以及我的一些经验总结。如果出现链接失效,或者想知道更多的内容等情况可以提交 Issues 提醒我修改相关内容。 PS:我的学习笔记,...

    designPattern3:设计模式3:适配器模式,篮球翻译适配器,游戏存进度,备忘录模式基本代码,游戏进度备忘

    designPattern3设计模式3:适配器模式,篮球翻译适配器,游戏存进度,备忘录模式基本代码,游戏进度备忘

    java-dj-view

    关于 MVC 的简短摘要 去做控制器 翻译成英语控制器是视图的一种策略(strategy pattern)。 一方面,他负责何时激活或停用哪些控件(例如按钮)。 此外,视图中触发的所有操作(例如按钮点击)都委托给控制器。 然后...

    PRML中文翻译

    机器学习经典著作《pattern recognition and machine learning》的中文翻译版本,机器学习入门必备!

    Spring Security-3.0.1中文官方文档(翻译版)

    21. Java 认证和授权服务(JAAS)供应器 21.1. 概述 21.2. 配置 21.2.1. JAAS CallbackHandler 21.2.2. JAAS AuthorityGranter 22. CAS 认证 22.1. 概述 22.2. CAS 是如何工作的 22.3. 配置CAS ...

    FontPatterMaker

    Font Pattern Maker 自動幫你補捉PC系統字型並轉換為12X18pixels的C語言陣列 Table for your application.

    RegularExpressionTutorial:RegularExpression教程项目通过大量示例解释了核心概念

    开发诸如编译器,解释器和汇编器之类的翻译器。 开发通信协议行TCP / IP,UDP等 正则表达概念 RegularExpression是Java 1.4版本发行的版本,并存在于java.util.regex软件包中。 RegularExpression是一种根据特定...

    DependencyInjection

    Martin Fowler的经典论文《Inversion of Control Containers and the Dependency Injection pattern》的中文翻译。In the Java community there's been a rush of lightweight containers that help to assemble ...

    积分管理系统java源码-my-nlp-task:汇总一些知名的开源项目,学习一下

    积分管理系统java源码 目前有一些自然语言处理工具,可以快速地完成NLP任务,如: NLTK:处于领先的地位,提供了 WordNet 、分类、分词、标注、语法分析、语义推理等类库。 Pattern:包括词性标注工具,N元搜索,情感...

    javascript正则表达式 | 知识梳理

    正则表达式由pattern和flags组成,我不知道怎么翻译这个,我用我自己的话解释一下,pattern可以理解为一个函数(做什么), flags可以理解为参数, 比如flags为g为全局匹配,i为忽略大小写。 字面量 这种方法最方便...

    二十三种设计模式【PDF版】

    翻译: 很多程序员在读完这本书,宣布自己相当于经历了一次"主显节"(纪念那稣降生和受洗的双重节日),如果你从来没有读 过这本书,你会在你的程序教育生涯里存在一个严重裂沟,所以你应该立即挽救弥补! 可以这么说:GoF ...

    DictGen:字典生成小工具

    DictGen:字典生成器 字典 SQL 的自动生成器。... INPUT_TRANSLATION_DIR是一个文件,您可以在其中放置密钥及其翻译(其他语言)。 此文件必须具有偶数行。 EXTENSION_PATTERN_MAP是扩展和模式映射。 每个条

    编译原理复习(期末不挂科)

    模式(pattern)是产生和识别元素的规则,记号(token)是按照某个模式识别出的元素,单词(lexeme)是被识别出的元素自身的值。 正规式 正规式是描述语言的规则,可以用来描述语言的语法结构。正规式的定义、字符...

    56丨观察者模式(上):详解各种应用场景下观察者模式的不同实现方式1

    观察者模式(Observer Design Pattern)是行为型设计模式的一种,主要解决的是“类或对象之间的交互”问题。它定义了一个一对多的依赖关系,当一个对象的状态改变时,所有依赖的对象都会自动收到通知。 观察者模式...

    asp.net知识库

    理解C#中的委托[翻译] 利用委托机制处理.NET中的异常 与正则表达式相关的几个小工具 你真的了解.NET中的String吗? .NET中的方法及其调用(一) 如何判断ArrayList,Hashtable,SortedList 这类对象是否相等 帮助解决...

    Spring-Reference_zh_CN(Spring中文参考手册)

    Ant风格的pattern 4.7.2.2. classpath*: 前缀 4.7.2.3. 其他关于通配符的说明 4.7.3. FileSystemResource 提示 5. 校验,数据绑定,BeanWrapper,与属性编辑器 5.1. 简介 5.2. 使用Spring的Validator接口进行校验 ...

Global site tag (gtag.js) - Google Analytics