• 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

doubt Regex

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I expected the output as..
Pattern is = 0[xX]([0-9a-fA-F])+
m.start() = 0 m.group = 0x1aA
m.start() = 14 m.group = 0xB

but the o/p is..
Pattern is = 0[xX]([0-9a-fA-F])+
m.start() = 0 m.group = 0x1aA012345 (why 012345 is also grouped)
m.start() = 14 m.group = 0xB


Thanks
regards
samura

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are putting + (one or more)sign after the pattern it keeps on matching until it find any digit or a Alphabet from A to F.
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here the search continues untill it finds the 'X' which is not included in your expression then search stops.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,
[0-9a-z]+ means one or more occurances of anything between 0 to 9 OR a to z . Also the order does not matter .
 
reply
    Bookmark Topic Watch Topic
  • New Topic