| Author |
Code: regex, formatted output, console
|
Christian Kindler
Greenhorn
Joined: Apr 16, 2009
Posts: 18
|
|
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
Posts: 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
|
 |
 |
|
|
subject: Code: regex, formatted output, console
|
|
|