• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

regarding regex syntax

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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" )
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks more like a printf formatter.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
+ 1 with David. Marcus, can you post your problem/requirement in detail?
 
Marshal
Posts: 80756
487
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 80756
487
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic