Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Q33 Mock Exam - OCP7 by Mala Gupta Book

 
Ranch Hand
Posts: 59
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q33) What is the output of the following code (Select the best option.)?


a) These are their,lea<>,,<>
b) These are <>,ir,leather,,them
c) These are <>ir,leather,<>m
d) These are <>ir,lea<>r<>m
e) These are their,lea<>r,,,<>m

The correct answer is said to be letter a. Why is it a and not letter e?

Thanks!

 
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

a) These are their,lea<>,,<>


The output should be this:
These are their,le<>,,<>
It's simple, you are matching "the" and 1 character before and after it. So when you replace, you'll replace "the" and the character before and after it...
 
Yin Stadfield
Ranch Hand
Posts: 59
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot that the character that \\S will match will be included on the replace as well, I thought it's only "the". Thanks, Ankit!
 
Always look on the bright side of life. At least this ad is really tiny:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic