2 // This software is now distributed according to
\r
3 // the Lesser Gnu Public License. Please see
\r
4 // http://www.gnu.org/copyleft/lesser.txt for
\r
6 // -- Happy Computing!
\r
8 package com.stevesoft.pat;
\r
12 /** This class implements the word boundary pattern element: \b. */
\r
13 class Boundary extends Pattern
\r
15 public String toString()
\r
17 return "\\b" + nextString();
\r
20 boolean isAChar(char c)
\r
22 if (c >= 'a' && c <= 'z')
\r
26 if (c >= 'A' && c <= 'Z')
\r
30 if (c >= '0' && c <= '9')
\r
41 boolean matchLeft(int pos, Pthings pt)
\r
47 if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos - 1)))
\r
54 boolean matchRight(int pos, Pthings pt)
\r
60 if (pos + 1 >= pt.src.length())
\r
64 if (isAChar(pt.src.charAt(pos)) && isAChar(pt.src.charAt(pos + 1)))
\r
71 public int matchInternal(int pos, Pthings pt)
\r
73 if (matchRight(pos - 1, pt) || matchLeft(pos, pt))
\r
75 return nextMatch(pos, pt);
\r
80 public patInt maxChars()
\r
82 return new patInt(0);
\r
85 public Pattern clone1(Hashtable h)
\r
87 return new Boundary();
\r