<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FRegular_Expressions%2FPattern_Match</id>
		<title>Java Tutorial/Regular Expressions/Pattern Match - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FRegular_Expressions%2FPattern_Match"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/Regular_Expressions/Pattern_Match&amp;action=history"/>
		<updated>2026-04-21T21:54:47Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/Regular_Expressions/Pattern_Match&amp;diff=2935&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/Regular_Expressions/Pattern_Match&amp;diff=2935&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:44, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/Regular_Expressions/Pattern_Match&amp;diff=2936&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/Regular_Expressions/Pattern_Match&amp;diff=2936&amp;oldid=prev"/>
				<updated>2010-05-31T15:19:11Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Find the end point of the second &amp;quot;B(ond)&amp;quot; ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.util.regex.Matcher;&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    Pattern p = Pattern.rupile(&amp;quot;B(on)d&amp;quot;);&lt;br /&gt;
    String candidateString = &amp;quot;My name is Bond. James Bond.&amp;quot;;&lt;br /&gt;
    String matchHelper[] = { &amp;quot;               ^&amp;quot;, &amp;quot;              ^&amp;quot;, &amp;quot;                           ^&amp;quot;,&lt;br /&gt;
        &amp;quot;                          ^&amp;quot; };&lt;br /&gt;
    Matcher matcher = p.matcher(candidateString);&lt;br /&gt;
    // Find the end point of the second &amp;quot;B(ond)&amp;quot;&lt;br /&gt;
    matcher.find();&lt;br /&gt;
    int endIndex = matcher.end(0);&lt;br /&gt;
    System.out.println(candidateString);&lt;br /&gt;
    System.out.println(matchHelper[2] + endIndex);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Match Duplicate Words ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.util.regex.Matcher;&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String args[]) throws Exception {&lt;br /&gt;
    String duplicatePattern = &amp;quot;\\b(\\w+) \\1\\b&amp;quot;;&lt;br /&gt;
    Pattern p = Pattern.rupile(duplicatePattern);&lt;br /&gt;
    &lt;br /&gt;
    int matches = 0;&lt;br /&gt;
    String phrase = &amp;quot;this is a test&amp;quot;;&lt;br /&gt;
    Matcher m = p.matcher(phrase);&lt;br /&gt;
    String val = null;&lt;br /&gt;
    while (m.find()) {&lt;br /&gt;
      val = &amp;quot;:&amp;quot; + m.group() + &amp;quot;:&amp;quot;;&lt;br /&gt;
      System.out.println(val);&lt;br /&gt;
      matches++;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Matching Line Boundaries in a Regular Expression ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.util.regex.Matcher;&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) throws Exception {&lt;br /&gt;
    CharSequence inputStr = &amp;quot;abc\ndef&amp;quot;;&lt;br /&gt;
    String patternStr = &amp;quot;abc$&amp;quot;;&lt;br /&gt;
    // Compile with multiline enabled&lt;br /&gt;
    Pattern pattern = Pattern.rupile(patternStr, Pattern.MULTILINE);&lt;br /&gt;
    Matcher matcher = pattern.matcher(inputStr);&lt;br /&gt;
    boolean matchFound = matcher.find(); // true&lt;br /&gt;
    // Use an inline modifier to enable multiline mode&lt;br /&gt;
    matchFound = pattern.matches(&amp;quot;.*abc$.*&amp;quot;, &amp;quot;abc\r\ndef&amp;quot;); // false&lt;br /&gt;
    matchFound = pattern.matches(&amp;quot;(?m).*abc$.*&amp;quot;, &amp;quot;abc\r\ndef&amp;quot;); // true&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Pattern.matches method ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    String regex = &amp;quot;ad*&amp;quot;;&lt;br /&gt;
    String input = &amp;quot;add&amp;quot;;&lt;br /&gt;
    boolean isMatch = Pattern.matches(regex, input);&lt;br /&gt;
    System.out.println(isMatch);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Regex for IP v4 Address ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/util/InetAddressUtils.java $&lt;br /&gt;
 * $Revision: 652020 $&lt;br /&gt;
 * $Date: 2008-04-27 22:23:31 +0100 (Sun, 27 Apr 2008) $&lt;br /&gt;
 * &lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements.  See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership.  The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *   http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied.  See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 *&lt;br /&gt;
 * This software consists of voluntary contributions made by many&lt;br /&gt;
 * individuals on behalf of the Apache Software Foundation.  For more&lt;br /&gt;
 * information on the Apache Software Foundation, please see&lt;br /&gt;
 * &amp;lt;http://www.apache.org/&amp;gt;.&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
/**&lt;br /&gt;
 * A collection of utilities relating to InetAddresses.&lt;br /&gt;
 */&lt;br /&gt;
public class InetAddressUtils {&lt;br /&gt;
    private InetAddressUtils() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private static final Pattern IPV4_PATTERN = &lt;br /&gt;
        Pattern.rupile(&lt;br /&gt;
                &amp;quot;^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$&amp;quot;);&lt;br /&gt;
    private static final Pattern IPV6_STD_PATTERN = &lt;br /&gt;
        Pattern.rupile(&lt;br /&gt;
                &amp;quot;^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$&amp;quot;);&lt;br /&gt;
    private static final Pattern IPV6_HEX_COMPRESSED_PATTERN = &lt;br /&gt;
        Pattern.rupile(&lt;br /&gt;
                &amp;quot;^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$&amp;quot;);&lt;br /&gt;
    public static boolean isIPv4Address(final String input) {&lt;br /&gt;
        return IPV4_PATTERN.matcher(input).matches();&lt;br /&gt;
    }&lt;br /&gt;
    public static boolean isIPv6StdAddress(final String input) {&lt;br /&gt;
        return IPV6_STD_PATTERN.matcher(input).matches();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static boolean isIPv6HexCompressedAddress(final String input) {&lt;br /&gt;
        return IPV6_HEX_COMPRESSED_PATTERN.matcher(input).matches();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static boolean isIPv6Address(final String input) {&lt;br /&gt;
        return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input); &lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Regex for IP v6 Address ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/conn/util/InetAddressUtils.java $&lt;br /&gt;
 * $Revision: 652020 $&lt;br /&gt;
 * $Date: 2008-04-27 22:23:31 +0100 (Sun, 27 Apr 2008) $&lt;br /&gt;
 * &lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one&lt;br /&gt;
 * or more contributor license agreements.  See the NOTICE file&lt;br /&gt;
 * distributed with this work for additional information&lt;br /&gt;
 * regarding copyright ownership.  The ASF licenses this file&lt;br /&gt;
 * to you under the Apache License, Version 2.0 (the&lt;br /&gt;
 * &amp;quot;License&amp;quot;); you may not use this file except in compliance&lt;br /&gt;
 * with the License.  You may obtain a copy of the License at&lt;br /&gt;
 *&lt;br /&gt;
 *   http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 *&lt;br /&gt;
 * Unless required by applicable law or agreed to in writing,&lt;br /&gt;
 * software distributed under the License is distributed on an&lt;br /&gt;
 * &amp;quot;AS IS&amp;quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY&lt;br /&gt;
 * KIND, either express or implied.  See the License for the&lt;br /&gt;
 * specific language governing permissions and limitations&lt;br /&gt;
 * under the License.&lt;br /&gt;
 *&lt;br /&gt;
 * This software consists of voluntary contributions made by many&lt;br /&gt;
 * individuals on behalf of the Apache Software Foundation.  For more&lt;br /&gt;
 * information on the Apache Software Foundation, please see&lt;br /&gt;
 * &amp;lt;http://www.apache.org/&amp;gt;.&lt;br /&gt;
 *&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.regex.Pattern;&lt;br /&gt;
/**&lt;br /&gt;
 * A collection of utilities relating to InetAddresses.&lt;br /&gt;
 */&lt;br /&gt;
public class InetAddressUtils {&lt;br /&gt;
    private InetAddressUtils() {&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    private static final Pattern IPV4_PATTERN = &lt;br /&gt;
        Pattern.rupile(&lt;br /&gt;
                &amp;quot;^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$&amp;quot;);&lt;br /&gt;
    private static final Pattern IPV6_STD_PATTERN = &lt;br /&gt;
        Pattern.rupile(&lt;br /&gt;
                &amp;quot;^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$&amp;quot;);&lt;br /&gt;
    private static final Pattern IPV6_HEX_COMPRESSED_PATTERN = &lt;br /&gt;
        Pattern.rupile(&lt;br /&gt;
                &amp;quot;^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$&amp;quot;);&lt;br /&gt;
    public static boolean isIPv4Address(final String input) {&lt;br /&gt;
        return IPV4_PATTERN.matcher(input).matches();&lt;br /&gt;
    }&lt;br /&gt;
    public static boolean isIPv6StdAddress(final String input) {&lt;br /&gt;
        return IPV6_STD_PATTERN.matcher(input).matches();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static boolean isIPv6HexCompressedAddress(final String input) {&lt;br /&gt;
        return IPV6_HEX_COMPRESSED_PATTERN.matcher(input).matches();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    public static boolean isIPv6Address(final String input) {&lt;br /&gt;
        return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input); &lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Validate email address ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    System.out.println(&amp;quot;isValid = &amp;quot; + isValidEmailAddress(&amp;quot;user@domain.ru&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
  static boolean isValidEmailAddress(String email) {&lt;br /&gt;
    String EMAIL_REGEX = &amp;quot;^[\\w-_\\.+]*[\\w-_\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$&amp;quot;;&lt;br /&gt;
    return email.matches(EMAIL_REGEX);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>