Page 1 of 1
About Question enthuware.ocpjp.v7.2.1180 :
Posted: Thu Nov 22, 2012 8:46 am
by ETS User
Hey,
The explanation by the second answer sounds wrong. If I understand it correctly, the explanation says basicly the regex is
, while it is
What indeed would result in the second answer.
If it is the regex how the explanation says, the explanation is at the wrong answer.
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Thu Nov 22, 2012 9:06 am
by admin
The explanation is correct. The first o in the given string is a match because it starts with a word boundary i.e. it matches \\bo
I think the words "... any o immediately follows a word boundary ..." ..should be... " any o that immediately follows a word boundary...".
HTH,
Paul.
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Thu Apr 18, 2013 3:51 pm
by RobynBackhouse
I'm confused as to why the word boundary itself is not replaced.
If the string is changed to "?O brother", only the "O" is replaced, and the word boundary itself (the ?) is left there, giving the result "?X brother".
Why does the replaceAll not replace the whole regex pattern result?
Thanks

Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Thu Apr 18, 2013 4:29 pm
by admin
Because word boundary is considered as zero length. It is not included in the matching value.
-Paul.
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Mon Apr 22, 2013 3:44 pm
by RobynBackhouse
Ah ok that makes sense.
Thanks.
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Fri Sep 20, 2013 3:42 am
by The_Nick
Hi,
In your explanation you mention that a word boundary matches also special characthers.. what kind of special characters are you talking about?
Thanks in advance.
The_Nick.
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Fri Sep 20, 2013 5:57 am
by admin
Anything that is not considered a word char i.e. a-zA-Z0-9_. So word boundary will match characters like ;- etc. Please see the JavaDoc for the exact list.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Sun Jan 22, 2017 4:55 am
by sir_Anduin@yahoo.de
what do you mean by
(Depending on ?m)
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Sun Jan 22, 2017 6:04 am
by admin
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Wed Oct 04, 2017 4:26 am
by horst1a
Where is the word boundary here, before the first o ?
Re: About Question enthuware.ocpjp.v7.2.1180 :
Posted: Wed Oct 04, 2017 8:43 pm
by admin
Yes, that is the first word boundary.