• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding regex syntax

 
Marcus Deviln
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" )
 
Henry Wong
author
Marshal
Pie
Posts: 21446
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks more like a printf formatter.
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
+ 1 with David. Marcus, can you post your problem/requirement in detail?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49865
71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic