• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regular expression

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone explain the meaning of the following pattern?

"^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\S.*)$"

Thanks.
 
author
Posts: 23951
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

Originally posted by Suman Sharma:
Can anyone explain the meaning of the following pattern?

"^\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\S.*)$"

Thanks.



This regular express will match ... the beginning of input, followed by zero or more whitespaces, followed by one or more digits (0-9), followed by one or more whitespaces, followed by one or more digits (0-9), followed by one or more whitespaces, followed by one or more digits (0-9), followed by one or more whitespaces, followed by a character that is not a whitespace, followed by zero or more of anything, followed by end of input.

Also, while this matching is taking place, place certain pieces in groups. This is so that these fields can be extracted after a successful match. The first group is the first set of one or more digits. The second group is the second set of one or more digits. The third group is the third set of one or more digits. And the last group is the a character that is not a whitespace, followed by zero or more of anything, at the end of input.

Henry
 
Suman Sharma
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much. You explained it very clearly.
 
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic