• 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

Question about Regular Expression

 
Ranch Hand
Posts: 51
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Jumping straight to the question. I have a minor confusion regarding (//b) however i do know that i marks the word boundaries bwteen a word character and non-word character.

Here is output (both lines are used separately)

0 2 3 4 5 (for using //Print Start Index Line)
0 2 3 4 5( for using //Print End Index Line)

K & B said that in boundary words we should assume that a non-word character is added to the beginning and ending of the string.

In case of running only //Print Start Index Line, it seems right as it prints start index of boundary between non-word characters and word characters.

In case of //Print End Index Line, i don't understood the same output, i assumed that the output would be (indexvalue for start + 1).

What i am missing here ? Why the output is same for print start index and printing end index ?

Thanks in advance ..
 
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

Kaxhif Khan wrote:
In case of //Print End Index Line, i don't understood the same output, i assumed that the output would be (indexvalue for start + 1).

What i am missing here ? Why the output is same for print start index and printing end index ?



Having an end index equal to "start + 1", implies that the size of the match is one... meaning one character should be returned as a match. The regular expression is "\\b", which is only a boundary. What would the one character be, that would match that regex? Isn't a boundary... well ... just a boundary? Why should it have any length (characters)?

Henry
 
reply
    Bookmark Topic Watch Topic
  • New Topic