• 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

Regex Help neaded

 
Ranch Hand
Posts: 100
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to get to grips with with Regex. Like the following example



The ? quantifier means 0 or 1 times. The output that i get is


Why is it getting 4 then a 3 then 0 from the end and not the first portion ?
 
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

Sajjad Ishaq wrote:Hi,

I am trying to get to grips with with Regex. Like the following example



The ? quantifier means 0 or 1 times. The output that i get is


Why is it getting 4 then a 3 then 0 from the end and not the first portion ?



When I ran it, I got this...

0 1 1
1 2 0
2 3 1
3 4 2
4 4
5 6 0
6 7 2
7 8 0
8 9 8
9 9
10 11 4
11 12 3
12 13 0
13 13



Looks correct to me.

Henry
 
Robert Darling
Ranch Hand
Posts: 100
Android Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops sorry. I was using eclipse and the console window had scrolled up so that only the last few lines were visible. But still can you explain the difference ebetween ?,* and +

Regards.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But still can you explain the difference ebetween ?,* and +



That is covered in the regex documentation. * stands for 0 or more matches. + stands for one or more matches.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic