• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

regex pattern to seaech for hexadecimal

 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This example is for one -digit hexadecimal numbers.

Expression:0[xX][0-9a-fA-F]
Source:"12 ox ox12 oXf oxg"
index: 012345678901234567

And answer is 6 & 11.

I am not getting why the answer is 6 & 11.

This example is from K & B book, chapter: 6 & page no:476.

can anyone help me?
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi dolly,

please be careful to not introduce typos.

The correct sample:

The expression looks first for a zero digit, followed by an x or an X, followed by an hexadecimal digit. The places 6 and 11 are the only ones where these conditions are fulfilled.
 
dolly shah
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I got it.
One more question, Why in book they have said that "\d" doesn't work. You have to type "\\d". But I am able to do "\d".
Page no:481, K & B,
Can you help me?
 
Manfred Klug
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by dolly shah:
Why in book they have said that "\d" doesn't work. You have to type "\\d". But I am able to do "\d".

Then you have a special compiler. For me it fails with 'illegal escape character'.
 
What's that smell? Hey, sniff this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic