• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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 .
 
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic