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