Java Doc for Regsub.java in  » Web-Server » Brazil » sunlabs » brazil » util » regexp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Brazil » sunlabs.brazil.util.regexp 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   sunlabs.brazil.util.regexp.Regsub

Regsub
public class Regsub (Code)
The Regsub class provides an iterator-like object to extract the matched and unmatched portions of a string with respect to a given regular expression.

After each match is found, the portions of the string already checked are not searched again -- searching for the next match will begin at the character just after where the last match ended.

Here is an example of using Regsub to replace all "%XX" sequences in a string with the ASCII character represented by the hex digits "XX":

 public static void
 main(String[] args)
 throws Exception
 {
 Regexp re = new Regexp("%[a-fA-F0-9][a-fA-F0-9]");
 Regsub rs = new Regsub(re, args[0]);
 StringBuffer sb = new StringBuffer();
 while (rs.nextMatch()) {
 sb.append(rs.skipped());
 String match = rs.matched();
 int hi = Character.digit(match.charAt(1), 16);
 int lo = Character.digit(match.charAt(2), 16);
 sb.append((char) ((hi << 4) | lo));
 }
 sb.append(rs.rest());
 System.out.println(sb);
 }
 

author:
   Colin Stevens (colin.stevens@sun.com)
version:
   1.4, 99/10/14
See Also:   Regexp


Field Summary
 intend
    
 Regexp.Matchm
    
 intmstart
    
 Regexpr
    
 Stringstr
    
 intustart
    

Constructor Summary
public  Regsub(Regexp r, String str)
     Construct a new Regsub that can be used to step through the given string, finding each substring that matches the given regular expression.

Method Summary
public  Stringmatched()
     Returns a substring consisting of the characters that matched the entire regular expression during the last call to nextMatch.
public  booleannextMatch()
     Searches for the next substring that matches the regular expression. After calling this method, the caller would call methods like skipped, matched, etc.
public  Stringrest()
     Returns a substring consisting of all the characters that come after the last match.
public  Stringskipped()
     Returns a substring consisting of all the characters skipped between the end of the last match (or the start of the original search string) and the start of this match.
public  Stringsubmatch(int i)
     Returns a substring consisting of the characters that matched the given parenthesized subexpression during the last call to nextMatch.

Field Detail
end
int end(Code)



m
Regexp.Match m(Code)



mstart
int mstart(Code)



r
Regexp r(Code)



str
String str(Code)



ustart
int ustart(Code)




Constructor Detail
Regsub
public Regsub(Regexp r, String str)(Code)
Construct a new Regsub that can be used to step through the given string, finding each substring that matches the given regular expression.

Regexp contains two substitution methods, sub and subAll, that can be used instead of Regsub if just simple substitutions are being done.
Parameters:
  r - The compiled regular expression.
Parameters:
  str - The string to search.
See Also:   Regexp.sub
See Also:   Regexp.subAll





Method Detail
matched
public String matched()(Code)
Returns a substring consisting of the characters that matched the entire regular expression during the last call to nextMatch. The characters that did match.
See Also:   Regsub.submatch



nextMatch
public boolean nextMatch()(Code)
Searches for the next substring that matches the regular expression. After calling this method, the caller would call methods like skipped, matched, etc. to query attributes of the matched region.

Calling this function again will search for the next match, beginning at the character just after where the last match ended. true if a match was found, falseif there are no more matches.




rest
public String rest()(Code)
Returns a substring consisting of all the characters that come after the last match. As the matches progress, the rest gets shorter. When nextMatch returns false, then this method will return the rest of the string that can't be matched. The rest of the characters after the last match.



skipped
public String skipped()(Code)
Returns a substring consisting of all the characters skipped between the end of the last match (or the start of the original search string) and the start of this match.

This method can be used extract all the portions of string that didn't match the regular expression. The characters that didn't match.




submatch
public String submatch(int i)(Code)
Returns a substring consisting of the characters that matched the given parenthesized subexpression during the last call to nextMatch.
Parameters:
  i - The index of the parenthesized subexpression. The characters that matched the subexpression, ornull if the given subexpression did notexist or did not match.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.