replay challenge
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of JBoss AS 5 Development this week in the JBoss forum
or Spring Dynamic Modules in Action in the Spring forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Professional Certification » Programmer Certification (SCJP)
 
RSS feed
 
New topic
Author

Code: regex, formatted output, console

Christian Kindler
Greenhorn

Joined: Apr 16, 2009
Messages: 14

To get familiar with regex, formatted output and the Console class, I wrote a small program. You can use it learn regex. You can change it / play around with it to solidify your knowledge. And of course you can look for bugs/errors or suggest improvements.

The program asks for a string to search in and a regex pattern. It prints matches with start and end index and it prints the original string with the matches highlighted in bold.

I don't know if printing in bold works in a windows console, it's tested on Linux with bash.

The program comes with no license, so you are totally free to use/change it

David Marco
Ranch Hand

Joined: Feb 23, 2009
Messages: 44

I think that Windows console does not allow for bold fonts. On my machine (Windows Server 2008) the program output shows like:

text to parse: abc1ef6hi7k
search pattern: \d
hit 1: 1 (start: 3, end: 4)
hit 2: 6 (start: 6, end: 7)
hit 3: 7 (start: 9, end: 10)
abc←[1m1←[0mef←[1m6←[0mhi←[1m7←[0mk

Greetings.



SCJP 6
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Professional Certification » Programmer Certification (SCJP)
 
RSS feed
 
New topic
aspose coverage