GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes regarding regex syntax Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regarding regex syntax" Watch "regarding regex syntax" New topic
Author

regarding regex syntax

Marcus Deviln
Ranch Hand

Joined: Jan 29, 2009
Posts: 39
Let's say you have some regex metadata with a conversion character like d. What is the purpose of the digits or integers that we sometimes see directly preceding the conversion character?(example: "%*4d/d" )


+Deviln+ The power of JAVA compels you!
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18876
    
  40

Marcus Deviln wrote:Let's say you have some regex metadata with a conversion character like d. What is the purpose of the digits or integers that we sometimes see directly preceding the conversion character?(example: "%*4d/d" )



Regex metadata? Conversion character? Can you first explain to us what you mean?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That looks more like a printf formatter.
Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 118
+ 1 with David. Marcus, can you post your problem/requirement in detail?


Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39079
    
  23
Look at the Formatter class or these sections in the Java™ Tutorials: 1 2 and 3. I can't seem to find the * character in Formatter, however. Are you sure about that?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3603
    
  15
Campbell Ritchie wrote:Look at the Formatter class or these sections in the Java™ Tutorials: 1 2 and 3. I can't seem to find the * character in Formatter, however. Are you sure about that?


Maybe it's not supported in Java, but in C, the '*' character allows you to specify the field width in the argument list

From the MS C++ docs
The second optional field of the format specification is the width specification. The width argument is a nonnegative decimal integer controlling the minimum number of characters printed.... If the width specification is an asterisk (*), an int argument from the argument list supplies the value.


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39079
    
  23
Joanne Neal wrote: . . . Maybe it's not supported in Java, but in C, . . .
No, it's not supported in Java, but thank you, Joanne. I had never seen that, not in the little C I have written.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding regex syntax