File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes WhizLabs Regex Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "WhizLabs Regex Question" Watch "WhizLabs Regex Question" New topic
Author

WhizLabs Regex Question

Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Hi guys,

Can anyone explain how the below code works ?


Thanks.


"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
Tamara Lopez
Ranch Hand

Joined: Feb 21, 2006
Posts: 63
Hi,
This question confused me too
(?i) turns on case insensitivity - so it will find any sequence of ill or ILL followed by a number. If you take out the (?i) it will only replace the hill2 bit.
I dont think we need to know the case insensitivity one for the exam.... there are a lot of questions that seem to have extra things in whizlabs.
Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Sure Tamara,

There's extra things charged in WhizLabs simulator.

I was able to understand how the "ill\\d" pattern works but I was unable to determine how the pattern "(?i)" works.

So, let's concentrate our analisys in "(?i)" pattern. Could you please Tamara explain step-by-step how the "(?i)" pattern works ?

As far as I know the pattern "?" means zero or one occurrences, so I'm unable to determine how can it mean about Case Sensitive.

Thanks.
Tamara Lopez
Ranch Hand

Joined: Feb 21, 2006
Posts: 63
I just looked it up and its what it said. To mean one or zero it would be after the character: eg: \\d* or \\d? or ([a-bA-b])+
Check for eg this page out:
http://www.regular-expressions.info/java.html

if you had i? that would mean zero or one i. or (i)?
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi guys,

(?i) is an embedded flag expression.

Check out the following page for more info:
http://java.sun.com/docs/books/tutorial/extra/regex/pattern.html

Joyce
Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Oh yeah. Now I see.

Embedded Flag Expression. That's the point.

Thank you so much for your prompt replies.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WhizLabs Regex Question